fix(site): preview lesson docs from the deploy's branch, not always main#289
Conversation
lesson.html hardcoded the raw.githubusercontent main branch for every lesson's markdown, so PR preview deploys (and any non-main branch) always rendered main's content. Content PRs could never be previewed before merge. build.js now writes build-meta.js with the build's git ref (VERCEL_GIT_COMMIT_REF, or local git, falling back to main); lesson.html reads window.__AIFS_REF and fetches docs/quiz from that branch. Production (main) is unchanged; PR previews now render their own lesson edits. build-meta.js is deploy-generated and gitignored.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR introduces a deployment metadata system that captures which git ref is being deployed and makes it available to the client. The build script generates a metadata file containing the git branch or commit ref, and the lesson page loads this metadata to fetch content from the correct GitHub branch instead of always using hardcoded ChangesDeployment git ref metadata
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ain (rohitg00#289) lesson.html hardcoded the raw.githubusercontent main branch for every lesson's markdown, so PR preview deploys (and any non-main branch) always rendered main's content. Content PRs could never be previewed before merge. build.js now writes build-meta.js with the build's git ref (VERCEL_GIT_COMMIT_REF, or local git, falling back to main); lesson.html reads window.__AIFS_REF and fetches docs/quiz from that branch. Production (main) is unchanged; PR previews now render their own lesson edits. build-meta.js is deploy-generated and gitignored.
Problem
lesson.htmlhardcoded the raw.githubusercontent main branch when fetching every lesson's markdown:So every deploy (production, PR preview, any branch) always rendered main's content. Content PRs (new lessons, the figure fences) could never be seen on their Vercel preview before merge.
Fix
build.jswritessite/build-meta.jswith the build's git ref:VERCEL_GIT_COMMIT_REFon Vercel, localgit rev-parseotherwise, falling back tomain.lesson.htmlloads it and fetches docs + quiz fromwindow.__AIFS_REFinstead of a hardcoded main.build-meta.jsis deploy-generated and gitignored (same pattern as sitemap.xml / llms.txt).Production is unchanged: on main, the ref is
main. PR previews now fetch from their own branch, so they render their own lesson edits.Validation (headless, real lesson.html)
.../fix/branch-aware-doc-fetch/.../en.md→ 200.window.__AIFS_REF= the branch; the lesson body and itsqlearning-gridworldfigure render from the branch's doc (mounted=1), zero blocking errors.quiz.jsonfor a quiz-less lesson, handled by the existing.catch(same as before).After this merges, PR #282 (figures wave 3) and every future content PR will preview correctly on Vercel.