From a06f5e8dc13358d64c0438f09d66ac4da19ed431 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Sat, 21 Feb 2026 09:28:45 -0700 Subject: [PATCH] Add Open Graph image generation for all docs pages Custom renderer with NASA-blue theme, Inter font, signal arc decoration. Generates 1200x630 PNG per page at build time via astro-opengraph-images. Head component injects og:image meta tag using getImagePath(). --- docs/astro.config.mjs | 27 +++++++- docs/package-lock.json | 14 ++++ docs/package.json | 4 ++ docs/src/components/Head.astro | 4 ++ docs/src/og-image.tsx | 114 +++++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 docs/src/og-image.tsx diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index c6b20dc..dee5851 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -3,11 +3,15 @@ import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; import icon from 'astro-icon'; import rehypeMermaid from 'rehype-mermaid'; +import opengraphImages from 'astro-opengraph-images'; +import { render as ogRender } from './src/og-image.tsx'; +import * as fs from 'node:fs'; -// astro-opengraph-images installed but needs font setup: -// import astroOpenGraphImages, { presets } from 'astro-opengraph-images'; +const interRegular = fs.readFileSync('node_modules/@fontsource/inter/files/inter-latin-400-normal.woff'); +const interBold = fs.readFileSync('node_modules/@fontsource/inter/files/inter-latin-700-normal.woff'); export default defineConfig({ + site: 'https://gr-apollo.l.warehack.ing', integrations: [ icon(), starlight({ @@ -57,6 +61,25 @@ export default defineConfig({ SocialIcons: './src/components/SocialIcons.astro', }, }), + opengraphImages({ + options: { + fonts: [ + { + name: 'Inter', + weight: 400, + style: 'normal', + data: interRegular, + }, + { + name: 'Inter', + weight: 700, + style: 'normal', + data: interBold, + }, + ], + }, + render: ogRender, + }), ], markdown: { rehypePlugins: [ diff --git a/docs/package-lock.json b/docs/package-lock.json index cf58376..47313ab 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -16,6 +16,10 @@ "mermaid": "^11.12.3", "rehype-mermaid": "^3.0.0", "sharp": "^0.34.2" + }, + "devDependencies": { + "@fontsource/inter": "^5.2.8", + "react": "^19.2.4" } }, "node_modules/@acemir/cssom": { @@ -986,6 +990,16 @@ "@expressive-code/core": "^0.41.6" } }, + "node_modules/@fontsource/inter": { + "version": "5.2.8", + "resolved": "https://registry.npmjs.org/@fontsource/inter/-/inter-5.2.8.tgz", + "integrity": "sha512-P6r5WnJoKiNVV+zvW2xM13gNdFhAEpQ9dQJHt3naLvfg+LkF2ldgSLiF4T41lf1SQCM9QmkqPTn4TH568IRagg==", + "dev": true, + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, "node_modules/@fortawesome/fontawesome-free": { "version": "6.7.2", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz", diff --git a/docs/package.json b/docs/package.json index d059914..39d2bcc 100644 --- a/docs/package.json +++ b/docs/package.json @@ -18,5 +18,9 @@ "mermaid": "^11.12.3", "rehype-mermaid": "^3.0.0", "sharp": "^0.34.2" + }, + "devDependencies": { + "@fontsource/inter": "^5.2.8", + "react": "^19.2.4" } } diff --git a/docs/src/components/Head.astro b/docs/src/components/Head.astro index baaacf3..1e883af 100644 --- a/docs/src/components/Head.astro +++ b/docs/src/components/Head.astro @@ -2,7 +2,11 @@ import type { Props } from '@astrojs/starlight/props'; import Default from '@astrojs/starlight/components/Head.astro'; import MermaidInit from './MermaidInit.astro'; +import { getImagePath } from 'astro-opengraph-images'; + +const ogImageUrl = getImagePath({ url: Astro.url, site: Astro.site }); --- + diff --git a/docs/src/og-image.tsx b/docs/src/og-image.tsx new file mode 100644 index 0000000..510ef47 --- /dev/null +++ b/docs/src/og-image.tsx @@ -0,0 +1,114 @@ +import React from "react"; +import type { RenderFunctionInput } from "astro-opengraph-images"; + +export async function render({ + title, + description, +}: RenderFunctionInput): Promise { + return ( +
+ {/* Signal arc decorations — top right */} + + + + + + + {/* Top: site name */} +
+ gr-apollo +
+ + {/* Middle: title + description */} +
+
+ {title} +
+ {description && ( +
+ {description} +
+ )} +
+ + {/* Bottom: tagline */} +
+ Apollo Unified S-Band Decoder + GNU Radio 3.10+ +
+
+ ); +}