Skip to content

fix(build): leave the output dir out of the listing pages - #634

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/ignore-site-dir
Oct 7, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/ignore-site-dir

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #632

Problem

cook build web copies each recipe's .cook source next to its page (_site/recipe/*.cook). When _site sits inside the recipe folder (the default), the next build finds recipes under it and the index lists _site as a folder. The link is dead too, since no directory/_site.html is written.

cook build (f6703df, #344) already prunes the output dir from the tree it walks (prune_output_subtree), but the index and directory pages go through build_recipes_template, which builds its own tree from disk and never pruned it.

Fix

  • RecipesBuildInput gets an exclude: Option<&Utf8Path> field. The static renderer passes the output dir; the server passes None.
  • The prune helper moves to web::builders::prune_subtree, used by both run_web and the listing builder.
  • find_todays_menu skips menus under the excluded dir, so a dated menu copied into _site/menu/ can't become "today's menu" on the next build.

Tests

  • tests/build.rs::build_twice_does_not_list_output_dir: builds twice into recipes/_site, then checks that neither index.html nor any directory/*.html mentions _site. It fails without the renderer change.
  • web::menus::tests::find_todays_menu_skips_excluded_dir.
  • cargo fmt, cargo clippy --all-targets and cargo test all pass. I also reproduced the issue's layout by hand (cook build web --base-url /recipes/, run several times): _site no longer shows up.

🤖 Generated with Claude Code

`cook build web` copies each recipe's source into `_site/recipe/`, so on
the next build with `_site` inside the recipe folder, the index and
directory pages listed `_site` as a folder (linking to a directory page
that is never written). The build already pruned the output dir from its
own recipe tree since f6703df (cooklang#344), but the listing pages rebuild a
tree from disk in `build_recipes_template`, which did not.

`RecipesBuildInput` now takes the dir to exclude and prunes it with the
same helper, and today's menu skips menus copied into it.

Closes cooklang#632

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@LeMyst
LeMyst marked this pull request as ready for review October 7, 2026 13:01
@LeMyst
LeMyst merged commit d324d5c into cooklang:main Oct 7, 2026
6 checks passed
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.

Ignore _site in static build

1 participant