Skip to content

integration: clear cached Markdown when the options change - #15

Merged
ewels merged 1 commit into
mainfrom
fix/md-content-cache-options
Oct 6, 2026
Merged

ewels merged 1 commit into
mainfrom
fix/md-content-cache-options

Conversation

@ewels

@ewels ewels commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Fixes #13.

Cause

  • Cached Markdown, not missing options
    • Astro's content layer renders .md pages once and stores the HTML, stylesheet link included, in .astro/data-store.json at the project root (not node_modules/.astro, which is why clearing that did nothing).
    • Astro clears that store only when its digest of the Astro config changes. The digest skips integrations and functions, so a change to the codeblocks() options never reached it.
    • .md pages kept linking the stylesheet of the old options, which the dev server no longer serves. .mdx pages are not stored this way, so they were fine.

Fix

  • Options digest on the Markdown processor
    • The integration writes a short hash of the resolved options to markdown.processor.options.starlightCodeblocks. Astro's digest covers that object, so any option change clears the store.
    • Sätteri and unified() read only the keys they know, so the extra key has no other effect.
    • It is in the shared integration hook, so the Starlight and the plain Astro entry points both get it.
    • A test in test/astro.test.ts checks that the same options give the same digest and that different options give a different one.

Verification

  • Reproduced on a copy of the nf-metro website
    • With 1.0.1, a full dev server restart after a change to footnotes still served .md pages that linked the old ec.*.css (404).
    • With this branch, .md and .mdx pages link the same served stylesheet after each change.
  • pnpm lint and pnpm test pass.

Not fixed here

  • Config edits while astro dev runs
    • Astro restarts the server in the same process but keeps the old content layer, with the old Markdown processor, and does not resync. .md pages stay stale until a full restart.
    • This affects any Markdown-related config change, so it needs a fix in Astro. A full restart is now enough, without deleting .astro/.

🤖 Generated with Claude Code

Astro's content layer keeps rendered .md pages until its digest of the
Astro config changes, and that digest skips integrations. Put a hash of
the options on the Markdown processor's options, which the digest covers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ewels
ewels merged commit 884596b into main Oct 6, 2026
3 checks passed
@ewels
ewels deleted the fix/md-content-cache-options branch October 6, 2026 23:49
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.

Dev: .md pages link a 404 Expressive Code stylesheet when an option such as footnotes: false changes the base styles

1 participant