Repository navigation
Description
Problem
Folders give each recipe exactly one place. A recipe like "red sauce pasta" belongs in lunch, dinner, pasta and easy meals all at once, and moving or copying the file is not an answer. This came up on Discord: someone wanted "collections" in cook server that can reference the same recipe file more than once.
Tags already cover the writing side. tags: [dinner, pasta] (or tags: dinner, pasta) in the frontmatter is parsed, and the server shows tags on the recipe cards (templates/recipes.html) and on the recipe page (templates/recipe.html). They are plain text, though, and no page lists "every recipe tagged dinner".
Proposal: tag pages
- Writing stays the same. Frontmatter
tags, on.cookand.menufiles. /tag/dinnershows every recipe and menu taggeddinner, from every folder, in one flat grid with the same cards as the home page. Each card shows its folder (Pasta/), so two recipes with the same name can be told apart. Sorted by name./tagslists every tag with its count (dinner · 14). The home page and the small-screen menu link to it.- Tags become links. On the recipe page,
#dinnerlinks to/tag/dinner. The tags on listing cards stay plain text for now, because each card is already a single<a>and a link cannot sit inside another link. - Matching ignores case and surrounding spaces:
Dinneranddinnerare the same tag, shown with the spelling seen first. There is no hierarchy, someal/dinneris just a name. - Static sites:
cook build webalso renderstags.htmlandtag/<name>.html.
Not in a first version, but possible follow-ups: combining tags (?tag=dinner&tag=easy), filter chips on folder pages, and cook search --tag.
Implementation sketch
- Collect: walk
cooklang_find::build_tree(base_path)once, assrc/build/index.rs::collectalready does (recipe.tags(), URL stem fromfile_name()). Factor that walk into a shared helper insrc/web/builders.rsthat both the new builders and the static search index use. - Templates: move the card markup out of
templates/recipes.htmlinto an include, so the tag page renders the same cards. Addtags.htmlandtag.htmlwith structs insrc/web/templates.rs, reusingRecipeItemwith an addedfolder: Option<String>. - Routes:
GET /tagsandGET /tag/{*tag}insrc/server/ui.rs, following therecipes_handlerpattern. Both are read-only GETs, soauth::middleware::required_capabilityneeds no change and thereaderrole can see them. - Static build:
render_tags/render_taginsrc/build/renderer.rs, called fromsrc/build/mod.rsnext torender_directory. File names are percent-encoded for tags containing spaces or/. Add the pages tositemap.rs. - i18n: a few new strings in all
locales/*/. - API:
/api/recipesalready returns normalisedtags, so API clients can filter today. No new endpoint is needed. - Tests: unit tests for the collector (case folding, menus, the same tag in two folders, untagged recipes); a
cook serverintegration test throughcommon::with_isolated_config; a Playwright test going from a recipe's tag to the tag page;cook build weboutput.
Activity
feat(server): tag pages, so a recipe can belong to several collections
feat(server): tag pages, so a recipe can belong to several collections