Skip to content

fix(landing): prerender with workerd#264

Merged
lentil32 merged 1 commit into
mainfrom
fixfixfixfxifx
May 31, 2026
Merged

fix(landing): prerender with workerd#264
lentil32 merged 1 commit into
mainfrom
fixfixfixfxifx

Conversation

@lentil32

@lentil32 lentil32 commented May 31, 2026

Copy link
Copy Markdown
Contributor

One-Line Summary

Landing now prerenders under Cloudflare workerd without losing generated Markdown sidecars used for SEO and GEO.

User-Facing Changes

  • Fixes the build path needed to run Astro Cloudflare prerendering with prerenderEnvironment: "workerd".
  • Preserves generated index.md sidecars for static HTML pages instead of dropping most docs pages during workerd builds.
  • Keeps local Accept: text/markdown negotiation working for collection index pages like /blog/.
  • Keeps the Cloudflare image service configured for compiled build images and Cloudflare Images binding runtime behavior.

Why This Changed

The landing build previously relied on Node prerendering because the workerd prerender path hit Node builtin imports from the docs rendering stack. Enabling Cloudflare nodejs_compat makes that prerender path viable, but the workerd build exposed a separate integration issue: Astro build assets did not include every emitted HTML page, so the agent Markdown exporter only generated a small subset of sidecars.

The local Markdown middleware also treated /blog/ as a blog content entry with an empty id, which caused getEntry() to throw instead of falling back to HTML-derived Markdown.

How It Changed

  • Switches the landing Cloudflare adapter to prerenderEnvironment: "workerd".
  • Adds nodejs_compat to the Wrangler compatibility flags so workerd can handle supported Node APIs used during prerendering.
  • Makes @onequery/astro-agent-markdown scan the emitted client directory for HTML files in addition to the Astro assets map.
  • Ignores empty content entry ids so collection index routes fall back to rendered HTML conversion.
  • Adds regression tests for HTML pages that are present on disk but missing from the assets map, and for collection index Markdown negotiation.

Bug Fixes

  • Under workerd prerendering, docs and other static HTML pages could be omitted from Markdown sidecar generation; this now exports sidecars from the emitted files on disk.
  • Under local dev Markdown negotiation, /blog/ could return a Vite error overlay because the content middleware called getEntry() with an empty id; this now returns Markdown for the rendered index page.
  • The prior Node-only prerender configuration prevented the landing app from matching Cloudflare runtime behavior during prerendering.

Extra Context / Decisions (Optional)

nodejs_compat is required because the prerender dependency graph includes supported Node builtin modules. The Markdown exporter now treats the final client output directory as the source of truth, which is more robust across Astro adapter runtime differences.

Verification

  • rtk bunx turbo test --filter=@onequery/astro-agent-markdown --json
  • rtk bun run build
  • rtk find dist/client -name "index.md" -type f
  • rtk bunx turbo typecheck --filter=@onequery/landing --filter=@onequery/astro-agent-markdown --json
  • rtk bunx turbo typecheck --filter=@onequery/astro-agent-markdown --json
  • rtk curl -H 'Accept: text/markdown' http://127.0.0.1:4546/blog/ -v
  • rtk curl -s -D - -o /tmp/blog-markdown-response.md -H 'Accept: text/markdown' http://127.0.0.1:4546/blog/
  • rtk bun run dev -- --port 4555 plus direct /_image/ fetch returned 200 image/webp
  • rtk bun run format
  • pre-push hook: lint-full passed with 0 warnings and 0 errors

Video / Screenshot (Optional)

  • N/A

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 31, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
onequery-landing 0955ffe Commit Preview URL

Branch Preview URL
May 31 2026, 05:43 PM

@lentil32 lentil32 enabled auto-merge (squash) May 31, 2026 17:42
@lentil32 lentil32 merged commit 8771927 into main May 31, 2026
8 checks passed
@lentil32 lentil32 deleted the fixfixfixfxifx branch May 31, 2026 17:44
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.

1 participant