Skip to content

fix: prerender markdown routes (hotfix — prod was missing body content)#31

Merged
threesam merged 1 commit into
mainfrom
fix/content-prerender
May 18, 2026
Merged

fix: prerender markdown routes (hotfix — prod was missing body content)#31
threesam merged 1 commit into
mainfrom
fix/content-prerender

Conversation

@threesam
Copy link
Copy Markdown
Owner

The bug

prod /canvas/self was serving just the hero — no markdown body. confirmed via curl: SSR HTML contained the hero <div> and <h1>self</h1> but no <article>/<Prose> block. same root cause on /dad and /benny.

Root cause

src/lib/content.ts reads markdown via fs.readFile(join(process.cwd(), 'content', ...)). Vercel's serverless functions run with process.cwd() === '/var/task' — the content/ directory at the repo root is NOT bundled into the function. The try/catch silently swallows ENOENT and returns null. Pages render with markdown = null → empty body.

Fix

export const prerender = true on the three affected +page.server.ts files. At build time process.cwd() IS the repo root, the read succeeds, HTML is baked. Zero runtime filesystem dependency. Same pattern PR #30 used for /shelf.

verified locally: prerendered canvas/self.html contains Dad, Trenton, Benny markdown body refs (grep matched).

Test plan

  • pnpm check: 0 errors
  • pnpm build: clean, all 3 routes prerendered
  • grep of prerendered HTML confirms markdown body baked in

Merge

Merge commit (no squash) per the usual.

🤖 Generated with Claude Code

content/ files are not bundled into the Vercel serverless function
(only static/ is). At runtime process.cwd() is /var/task and reads
fail silently, so getContent returns null and pages render with no
body — confirmed on prod: /canvas/self served just the hero.

Prerendering moves the markdown read to build time (where cwd is the
repo root and content/ exists). HTML gets baked. No runtime fs read.
Same pattern as /shelf in PR #30.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
garden Ready Ready Preview, Comment May 18, 2026 5:27pm

@threesam threesam merged commit 2b7a2ac into main May 18, 2026
1 of 2 checks passed
@threesam threesam deleted the fix/content-prerender branch May 18, 2026 17:26
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