Skip to content

feat(server): tag pages, so a recipe can belong to several collections - #795

Merged
LeMyst merged 2 commits into
cooklang:mainfrom
LeMyst:feat/tag-pages
Nov 29, 2026
Merged

LeMyst merged 2 commits into
cooklang:mainfrom
LeMyst:feat/tag-pages

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

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 tags in their frontmatter, and the server showed them, but nothing listed "every recipe tagged dinner".

What changes

/tags: every tag, the most used as collections

  • The six most used tags are cards, like collections. Each has a cover made of up to four pictures of its recipes (one, two side by side, one beside two, or two by two), a # disc when none of them has a picture, how many recipes carry it, and the names of the first three.
  • When there are more tags, All tags lists every one of them, A–Z under its first letter. The letter drops accents, so Été is under E, 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.
  • The Tags button on the listing opens it.

/tag/<tag>: every recipe and menu with that tag, from any folder

  • Narrow down: a row of the other tags these recipes carry, with how many carry each. Picking quick on #italian keeps 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.
  • The dice button opens one of the recipes still shown, at random: "what's for dinner?" on #dinner.
  • Sort by name, modified or created date, as on the listing. The listing's sort script moves to static/js/recipe-sort.js, which both pages use.
  • The tag's cover sits beside its name, the same mosaic as its card on /tags, when its recipes have pictures.
  • Each card names its folder (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.
  • A tag that no recipe carries answers 404, with the page's empty state.

Narrowing down, the dice and sorting run in the browser, so cook build web gets them too. With JavaScript off, the page is still the full list.

Everywhere else

  • Recipe cards show time, servings and difficulty (⏱️ 20 min · 👥 6 · 📊 advanced), taken from the recipe's time, servings and difficulty metadata as written. The card is shared, so this applies to the listing and the search page too.
  • The tags on a recipe page are links to their tag pages.
  • Matching ignores case and surrounding spaces: Dinner and dinner are 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 web writes tags.html and tag/<slug>.html, and lists them in sitemap.xml when the sitemap is enabled. The index's covers link their pictures from the site root, and the tag pages' covers from tag/.
  • --recipes-only guests can read both pages: they are added to RECIPE_READS. Both routes are GET-only, so the sign-in tables need nothing else.
  • The card markup is shared through templates/recipe_card.html, now used by the listing, the search page and the tag page. The per-recipe part of the listing builder is builders::recipe_item, which web::tags reuses.
  • New strings, translated in all 10 locales (Greek included). docs/server.md gets a Tags section, and docs/build.md lists 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:

Tag index

The same list, ordered by Most used, and filtered with ca (which matches mexican):

Tag index, most used first

Tag index, filtered

/tag/italian: its cover, Narrow down, sort and the dice. Caprese comes from Salads/:

Tag page

Narrowed down to #quick (/tag/italian?and=quick):

Tag page narrowed down

The listing, with the Tags button and the time, servings and difficulty on the cards:

Listing

The linked tags under a recipe's title:

Recipe tags

Dark mode

Tag index, dark

Tag page, dark

Phone width

Tag index at phone width Tag page at phone width

Tests

  • src/web/tags.rs unit tests cover:
    • slugs: case, unsafe characters, .., .hidden, trailing dots
    • grouping across folders, with spellings merged under the most used one, menus included and untagged recipes left out
    • the popular cards: most used first, the recipe names and the "+N", no list when every tag fits as a card
    • the A–Z letters: accents dropped, # last
    • the Narrow down tags, most shared first, and the page's own tag first on each card
    • the cover's first four pictures
    • the empty page of an unknown tag
  • tests/tag_pages_test.rs (server through common::with_isolated_config):
    • the popular cards: order, count, names, cover
    • the A–Z list and the most used order
    • a tag page with recipes and a menu from three folders, with a recipe tagged [dinner, Dinner] listed once
    • the Narrow down chips, the cards' data-tags and the count line in every plural
    • time, servings and difficulty on the listing's and the tag page's cards
    • /tag/QUICK is the same page as /tag/quick
    • an unknown tag returns 404
    • a recipe page links its non-ASCII tag (crème)
    • the listings link /tags
    • --recipes-only guests can read both pages
    • the static build writes the same pages, with working relative links and cover pictures
  • tests/e2e/tags.spec.ts:
    • from a recipe's #italian to the tag page, then on to a recipe in Salads/
    • from the listing's Tags button to the index, then on to a tag page
    • narrowing #italian down to #quick: the URL, the count, hidden chips, highlighted tags, a reload, then Clear
    • the dice opening one of the recipes
    • filtering and reordering the index
  • cargo fmt, cargo clippy --all-targets (also with --no-default-features --features server,lsp) and cargo test --workspace pass with no warnings.
  • Playwright (Chromium, full suite): everything passes except 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's check() sees the box change, so check() 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

@davidpkj

Copy link
Copy Markdown
Contributor

Why is this still a draft? Is there more planned for this PR?

LeMyst and others added 2 commits November 29, 2026 14:11
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 added a commit to LeMyst/cookcli that referenced this pull request Nov 29, 2026
@LeMyst
LeMyst marked this pull request as ready for review November 29, 2026 15:08
@LeMyst
LeMyst merged commit a0ce37a into cooklang:main Nov 29, 2026
7 checks passed
@LeMyst

LeMyst commented Nov 29, 2026

Copy link
Copy Markdown
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:

  • covers for the most used tags
  • an A–Z list of every tag
  • a way to narrow a tag down by a second one (/tag/dinner?and=easy)
  • a random pick among the recipes shown
  • time, servings and difficulty on the recipe cards

That's all merged now, thanks for asking!

Analysis and recommendations/changes made by Claude, posted on behalf of @LeMyst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(server): tag pages, so a recipe can belong to several collections

2 participants