Skip to content

fix(build): advertise the web feeds on static pages built with --feed - #676

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/static-feed-links
Oct 11, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/static-feed-links

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #595

Problem

cook build web --feed writes atom.xml and rss.xml at the output root, but the <link rel="alternate"> autodiscovery tags added in 353941f (#521) sit inside {% if !static_mode %} in templates/base.html. Static sites never point feed readers at their feeds, so a reader given the site's address finds nothing. As @drawmeanelephant found in the issue, cook server was already fine.

Fix

  • FeatureFlags gains feeds. It defaults to true, since cook server always serves the feeds (recipes-only guests included, because /atom.xml and /rss.xml are on their allowlist).
  • cook build web sets it to whether this build writes the feeds (--feed), and passes it through render_index / render_directory / render_recipe instead of FeatureFlags::default().
  • base.html tests features.feeds instead of !static_mode. The hrefs keep using {{ prefix }}, so they resolve from every page depth (./atom.xml, ../atom.xml, ../../atom.xml) and from --base-url when it is set.
  • Without --feed, static pages still carry no feed links, so they never point at files that don't exist.

There is no feed.json: the issue suggested JSON Feed too, but only Atom and RSS exist, so only those are advertised.

Tests

  • tests/build.rs: build_writes_feeds_when_feed_set now checks that the index, a directory page, a recipe page and a menu page link both feeds with the right relative prefix. build_omits_feeds_when_feed_not_set checks that pages carry no rel="alternate".
  • tests/server_feed_test.rs::pages_advertise_the_feeds still passes, so the server side is unchanged.
  • cargo fmt, cargo clippy --all-targets (no warnings) and cargo test all pass.

🤖 Generated with Claude Code

`cook build web --feed` writes atom.xml and rss.xml at the output root,
but the `<link rel="alternate">` tags added in 353941f sat inside
`{% if !static_mode %}`, so static pages never pointed feed readers at
them.

FeatureFlags gains `feeds`: always on for `cook server`, and on for a
static build only when it writes the feeds. base.html tests that flag
instead of static_mode; hrefs use the page's prefix, so they resolve
from any depth (./atom.xml, ../atom.xml, ../../atom.xml) or from
--base-url.

Closes cooklang#595

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@LeMyst
LeMyst marked this pull request as ready for review October 10, 2026 21:10
@LeMyst
LeMyst merged commit 94c27e5 into cooklang:main Oct 11, 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.

(cook build web) Make web feed (RSS) discoverable

1 participant