Dynamic OG images for docs pages#8527
Conversation
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Five Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
There was a problem hiding this comment.
Pull request overview
This PR adds build-time generation of per-page Open Graph (OG) images so social link unfurls can show the specific page title (e.g. <Suspense> or useState) instead of a generic section banner. It introduces a static image generation script (Satori + Resvg) that runs during the build and updates the page SEO metadata to reference the generated assets.
Changes:
- Add
scripts/generateOgImages.mjsto render OG cards for content pages intopublic/images/og/at build time. - Update
Page.tsxto pointog:imageto the per-page generated PNG when applicable, otherwise fall back to existing section images. - Add required dependencies (
satori,@resvg/resvg-js), wire the script intonpm run build, and ignore generated outputs in git.
Reviewed changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Adds lockfile entries for Satori/Resvg and transitive deps used for image generation. |
| src/components/Layout/Page.tsx | Switches OG image selection to prefer per-page generated images. |
| scripts/generateOgImages.mjs | New build-time generator for static OG card PNGs for content routes. |
| package.json | Adds deps and runs OG generation after next build. |
| .gitignore | Ignores generated public/images/og/ output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Generates a per-page social card so links unfurl with the actual page name (for example
<Suspense>) instead of the generic "API Reference" banner.The cards are generated statically at build time (no runtime image generation):
scripts/generateOgImages.mjsruns afternext build, renders a card for every content page with satori, and writes them topublic/images/og/.Page.tsxpointsog:imageat the static file. The homepage and error pages keep their existing static images.Numbers from a local run: 219 images, 24MB, ~25s added to the build.
Examples
<Suspense>)useState)Notes
public/fonts/(converted from the woff2 files already in the repo).<link>,<meta>,<script>,<style>).node scripts/generateOgImages.mjs, then checkpublic/images/og/.