fix: prerender markdown routes (hotfix — prod was missing body content)#31
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsreads markdown viafs.readFile(join(process.cwd(), 'content', ...)). Vercel's serverless functions run withprocess.cwd() === '/var/task'— thecontent/directory at the repo root is NOT bundled into the function. The try/catch silently swallows ENOENT and returnsnull. Pages render withmarkdown = null→ empty body.Fix
export const prerender = trueon the three affected+page.server.tsfiles. At build timeprocess.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.htmlcontainsDad,Trenton,Bennymarkdown body refs (grep matched).Test plan
pnpm check: 0 errorspnpm build: clean, all 3 routes prerenderedMerge
Merge commit (no squash) per the usual.
🤖 Generated with Claude Code