Website OG Images
OG images are automatically generated for all documentation pages at build time.
Overview
Section titled “Overview”The website generates 49 OpenGraph images (1200x630px) for sharing on social media. Each image includes:
- Category-coded accent strip (color varies by section)
- Project logo (
;+ “sql-splitter”) - Category label (Command, Guide, Reference, etc.)
- Page title
- Description from frontmatter
Category Colors
Section titled “Category Colors”| Section | Color | Hex |
|---|---|---|
| Commands | Blue | #58a6ff |
| Getting Started | Green | #3fb950 |
| Guides | Green | #3fb950 |
| Reference | Purple | #d2a8ff |
| Advanced | Orange | #ffa657 |
| Contributing | Pink | #f778ba |
| Tools | Blue | #79c0ff |
| Roadmap | Purple | #a371f7 |
Implementation
Section titled “Implementation”OG images are generated using Satori (Vercel’s JSX-to-SVG library) and converted to PNG with @resvg/resvg-js.
Key Files
Section titled “Key Files”| File | Purpose |
|---|---|
src/pages/og/[...slug].png.ts | Dynamic route that generates OG images for each doc |
src/pages/og/satori-lib.mjs | Satori template with category detection and styling |
Generation Process
Section titled “Generation Process”- At build time, Astro fetches all docs from the
docscontent collection - For each doc,
getStaticPaths()creates a route at/og/{slug}.png - The
GEThandler renders the Satori template to SVG - Resvg converts SVG to PNG
- Images are saved to
dist/og/with.pngextension
Example Output
Section titled “Example Output”dist/og/index.png # Homepagedist/og/commands/split.png # split command pagedist/og/getting-started/installation.pngdist/og/guides.png # Section index pagesdist/og/reference/dialects.png...Modifying the Template
Section titled “Modifying the Template”Edit src/pages/og/satori-lib.mjs to change the OG image design:
export async function generateOgSvg({ title, description, slug }) { // ... category detection and color assignment
const element = { type: 'div', props: { style: { /* Satori JSX element */ }, children: [/* ... */], }, };
return await satori(element, { width: 1200, height: 630, fonts: [...] });}Regenerating Images
Section titled “Regenerating Images”cd websitenpm run buildOG images are rebuilt with every static build (not during dev mode).
Homepage Image
Section titled “Homepage Image”The homepage (src/pages/index.astro) uses a separate BaseLayout that references a static OG image at /og-image.png. This image should be placed in the public/ directory.
To set up the homepage OG image:
- Create
website/public/og-image.png(1200x630px) - The file will be served at
https://sql-splitter.dev/og-image.png
Alternatively, you can update src/layouts/BaseLayout.astro to use the dynamically generated /og/index.png instead.