fix: serve static Open Graph images on Cloudflare - #30
Conversation
Docs pages pointed og:image at a next/og route that 500s on Workers. Pre-render the cards into public/og so crawlers get real PNGs. Co-authored-by: sharmaji582009 <sharmaji582009@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (15)
📒 Files selected for processing (10)
💤 Files with no reviewable changes (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change moves documentation Open Graph image generation from a runtime route to a build-time PNG pipeline. It adds shared path helpers, updates page metadata, runs generation during builds, removes the old route and renderer, and adds tests for the static image pipeline. ChangesStatic documentation OG images
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant BuildScript
participant OgLibrary
participant Docs
participant PublicFiles
BuildScript->>OgLibrary: call buildOgImages()
OgLibrary->>Docs: discover and parse MDX pages
OgLibrary->>OgLibrary: render documentation pages as PNG
OgLibrary->>PublicFiles: write static OG image files
PublicFiles-->>BuildScript: return generated file paths
Merge Risk: ⚪ Minimal · up to The static OG-image migration is ready to merge: documentation card generation completes successfully and deployment paths generate the required assets before building. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 6 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 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 |
|
Cloudflare preview is ready.
Production (23rd.dev) is unchanged. This preview URL stays the same as you push to this PR. |
Problem
Docs pages emit
og:image/twitter:imageashttps://23rd.dev/og/docs/.../image.png. That URL was anext/ogImageResponseroute. On Cloudflare Workers it dies immediately (500 Server failed to respondin a few ms). Slack, Discord, X, and iMessage therefore get no preview card.The static
app/opengraph-image.pngalready works. The broken route overrode it on every docs page.next/og(Satori + yoga.wasm) is a known bad fit for this OpenNext/Cloudflare deploy — the same reason the earlier catch-allopengraph-image.tsxhad to be moved offapp/docs/[[...slug]].Fix
public/og/docs/.../image.png(pnpm og:build)/og/docs/[...slug]route so Workers never loadnext/ogpnpm build,pnpm preview, andpnpm cf:deployall runog:buildfirst so new docs pages get a card.Verify
Summary by CodeRabbit