Skip to content

feat: custom OG image generation with SVG template#408

Open
achalvs wants to merge 4 commits intomainfrom
achal/og-images
Open

feat: custom OG image generation with SVG template#408
achalvs wants to merge 4 commits intomainfrom
achal/og-images

Conversation

@achalvs
Copy link
Contributor

@achalvs achalvs commented Mar 21, 2026

Summary

  • Custom OG image handler using the MPP brand SVG template rendered server-side with resvg
  • Licensed VTC Du Bois font files served from Vercel Blob (trial fonts removed from repo)
  • Per-route descriptions from scripts/og-descriptions.json
  • Smart title wrapping with balanced line distribution
  • Category/subcategory breadcrumbs with folder icon
  • Static og.png for landing page, dynamic /api/og for all doc routes

Before / After

Before (Vocs default):

before

After (custom template):

after

Files changed

  • src/pages/_api/api/og.tsx — resvg-based SVG template renderer
  • src/pages/_api/api/og-template.svg — brand SVG template
  • scripts/og-descriptions.json — per-route OG descriptions
  • scripts/upload-fonts.ts — Vercel Blob font uploader
  • scripts/generate-og-images.ts — batch preview generator
  • vercel.json — font rewrite to Blob
  • vocs.config.ts — pass path param in ogImageUrl
  • .gitignore — exclude licensed font files
  • _root.css / _layout.tsx — licensed font refs

Test plan

  • Generate all 41 route OG images locally
  • Verify on Vercel preview deployment
  • Test link unfurling on Twitter/Slack/Discord

- Replace Vocs default OG handler with resvg-based SVG template renderer
- SVG template with ASCII art background, MPP logo, category/subcategory
- Smart title wrapping with balanced line distribution (balanceLines)
- Per-route descriptions via scripts/og-descriptions.json
- Licensed VTC Du Bois font served from Vercel Blob (replaces trial .woff2)
- Static og.png for landing page, dynamic /api/og for all other routes
- Vercel rewrite proxies /fonts/VTCDuBois-* from Blob storage
- Font files gitignored; upload via scripts/upload-fonts.ts
@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mpp Ready Ready Preview, Comment Mar 21, 2026 5:43am

Request Review

"rewrites": [
{
"source": "/fonts/VTCDuBois-:path*",
"destination": "https://wgfdjv2jfqz2dlpx.public.blob.vercel-storage.com/fonts/VTCDuBois-:path*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.env.local

# Licensed font files (served via Vercel Blob in production)
public/fonts/VTCDuBois*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,40 @@
import { readFileSync } from "node:fs";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this?

@@ -0,0 +1,48 @@
{
"/overview": "The open protocol for machine-to-machine payments, built on an open IETF specification for HTTP 402",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the default here? its a little gnarly we need to manually maintain this -- can we not just pull from vocs frontmatter?

@@ -0,0 +1,170 @@
import { existsSync, mkdirSync, readFileSync } from "node:fs";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check this one in?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an interntional revert?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check in these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants