Repository navigation
feat(server): tag pages, so a recipe can belong to several collections - #795
Merged
Merged
Conversation
LeMyst
force-pushed
the
feat/tag-pages
branch
from
October 27, 2026 18:53
bf338bc to
3d7435c
Compare
Contributor
|
Why is this still a draft? Is there more planned for this PR? |
A folder gives a recipe one place; its frontmatter `tags` now give it as many as it has. `/tags` lists every tag with how many recipes carry it, and `/tag/<slug>` shows every recipe and menu with that tag from any folder, each card naming its folder. The tags on a recipe page link to their tag pages, and the listings get a Tags button. Tags match without regard to case or surrounding spaces. The slug is the lowercased tag with characters a file name cannot hold turned into `-`, so the server and `cook build web`, which writes `tags.html` and `tag/<slug>.html` (and lists them in the sitemap), agree on every page. Both routes are guest-readable under --recipes-only. The recipe card moves into `recipe_card.html`, shared by the listing and the tag page. Closes cooklang#785 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first tag pages were a list of pills and a grid. They now make use of what tags are for. `/tags` shows the six most used tags as cards: a cover of up to four pictures of their recipes, their count and their first recipes. Past those, every tag follows A–Z under its first letter (accents dropped, `#` for the rest), or most used first, with a filter box. `/tag/<slug>` gets its cover beside its name and a "Narrow down" row: the other tags of its recipes, with counts that follow each pick. The picked tags stay in the URL (`?and=quick`), and a tag no recipe left carries is hidden. A dice button opens one of the recipes shown, and they sort like the listing, whose script moves to recipe-sort.js. Cards bring the page's tag and the picked ones to the front, highlighted. All of it runs client-side, so `cook build web` has it too. Recipe cards, here, on the listing and in search, show the recipe's time, servings and difficulty metadata. Co-Authored-By: Claude Opus 5.5 <[email protected]>
LeMyst
force-pushed
the
feat/tag-pages
branch
from
November 29, 2026 14:13
3d7435c to
0b41f20
Compare
LeMyst
added a commit
to LeMyst/cookcli
that referenced
this pull request
Nov 29, 2026
LeMyst
marked this pull request as ready for review
November 29, 2026 15:08
Collaborator
Author
|
@davidpkj It was waiting on a redesign of the tag pages. The first version was a plain list of tags and a grid. The pages now have:
That's all merged now, thanks for asking! Analysis and recommendations/changes made by Claude, posted on behalf of @LeMyst. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #785
Why
A folder gives a recipe one place, but "red sauce pasta" belongs in lunch, dinner, pasta and easy meals at once. Recipes already carry
tagsin their frontmatter, and the server showed them, but nothing listed "every recipe tagged dinner".What changes
/tags: every tag, the most used as collections#disc when none of them has a picture, how many recipes carry it, and the names of the first three.Étéis underE, and a tag that doesn't start with a letter goes under#. A toggle switches to Most used first. A filter box finds a tag by name, ignoring case and accents./tag/<tag>: every recipe and menu with that tag, from any folderquickon#italiankeeps the recipes tagged both. Picking another tag narrows further, and the counts follow. A tag none of the remaining recipes carries is hidden, so the page never goes empty. The picked tags stay in the URL (/tag/italian?and=quick), so the narrowed page can be reloaded, shared or bookmarked. Clear resets it. This answers the "dinner and easy" follow-up I had left out of the first version.#dinner.static/js/recipe-sort.js, which both pages use./tags, when its recipes have pictures.Salads/), so recipes with the same name can be told apart. Each card also brings the tag, and the tags picked to narrow it down, to the front of its tags, highlighted.404, with the page's empty state.Narrowing down, the dice and sorting run in the browser, so
cook build webgets them too. With JavaScript off, the page is still the full list.Everywhere else
time,servingsanddifficultymetadata as written. The card is shared, so this applies to the listing and the search page too.Dinneranddinnerare one tag, shown with the spelling most recipes use. In the URL, the tag is lowercased and the characters a file name cannot hold (/ \ : ? * " < > | # %) become-. The server and the static site use the same slug, so they always agree on which page a recipe is listed on.cook build webwritestags.htmlandtag/<slug>.html, and lists them insitemap.xmlwhen the sitemap is enabled. The index's covers link their pictures from the site root, and the tag pages' covers fromtag/.--recipes-onlyguests can read both pages: they are added toRECIPE_READS. Both routes are GET-only, so the sign-in tables need nothing else.templates/recipe_card.html, now used by the listing, the search page and the tag page. The per-recipe part of the listing builder isbuilders::recipe_item, whichweb::tagsreuses.docs/server.mdgets a Tags section, anddocs/build.mdlists the new files.The tags on listing cards stay plain text: each card is already one
<a>, and a link cannot sit inside another link.Not included, as a possible follow-up:
cook search --tag.Screenshots
These were taken on the seed recipes. I added made-up pictures to them (an emoji on a gradient) so the covers have something to show. Only Easy Pancakes' photo comes with the seed.
/tags: the most used tags as collections, then every tag A–Z:The same list, ordered by Most used, and filtered with
ca(which matchesmexican):/tag/italian: its cover, Narrow down, sort and the dice. Caprese comes fromSalads/:Narrowed down to
#quick(/tag/italian?and=quick):The listing, with the Tags button and the time, servings and difficulty on the cards:
The linked tags under a recipe's title:
Dark mode
Phone width
Tests
src/web/tags.rsunit tests cover:..,.hidden, trailing dots#lasttests/tag_pages_test.rs(server throughcommon::with_isolated_config):[dinner, Dinner]listed oncedata-tagsand the count line in every plural/tag/QUICKis the same page as/tag/quick404crème)/tags--recipes-onlyguests can read both pagestests/e2e/tags.spec.ts:#italianto the tag page, then on to a recipe inSalads/#italiandown to#quick: the URL, the count, hidden chips, highlighted tags, a reload, then Clearcargo fmt,cargo clippy --all-targets(also with--no-default-features --features server,lsp) andcargo test --workspacepass with no warnings.sign-in-notice.spec.ts › a tick refused after signing out says so and offers to sign in. The page behaves as intended: it shows the notice and takes the tick back. On my machine, though, the refusal comes back before Playwright'scheck()sees the box change, socheck()fails. This change doesn't touch that page or the spec, and the spec passes on main's CI. The shopping-list specs that clash over shared seed files when run in parallel pass with--workers=1, as on CI.🤖 Generated with Claude Code