Skip to content

Migrate docs-sip to Vercel: client-side Mermaid + deploy config - #95

Merged
rz1989s merged 3 commits into
mainfrom
fix/vercel-mermaid-client-render
May 31, 2026
Merged

Migrate docs-sip to Vercel: client-side Mermaid + deploy config#95
rz1989s merged 3 commits into
mainfrom
fix/vercel-mermaid-client-render

Conversation

@rz1989s

@rz1989s rz1989s commented May 31, 2026

Copy link
Copy Markdown
Member

Prepares docs-sip for Vercel hosting (migrating off VPS reclabs3).

Problem

The build renders Mermaid diagrams to SVG at build time via rehype-mermaid's img-svg strategy, which launches a headless Chromium (Playwright). Vercel's build image can't launch it — libnspr4.so: cannot open shared object file (other Chromium system libs are missing too, with no apt to install them). Build fails.

Fix

  • Switch rehype-mermaid to the pre-mermaid strategy → emits <pre class="mermaid"> and renders client-side in the browser.
  • New Starlight <Head> override (src/components/Head.astro) runs the client renderer: theme-aware (re-renders on light/dark toggle via a MutationObserver), view-transition-safe (astro:page-load), and lazy (loads mermaid only on pages with a diagram).
  • mermaid added as a direct dep; playwright retained (mermaid-isomorphic imports it at module load even under pre-mermaid) but never launched, and its browser download is skipped on Vercel.

Deploy config

  • vercel.json: pins build to npm run build (so the docs:api TypeDoc step runs — Astro's default would skip it) and skips the Playwright browser download at install.
  • .vercelignore: drops dist/ and the generated reference/ from the upload.

Validation (Vercel preview)

  • Build green — 1,277 pages
  • All 4 Mermaid blocks on /architecture/ render to SVG (0 errors); re-render correctly on dark↔light toggle
  • Pagefind search returns results (161 for "stealth", incl. generated API reference)

DNS cutover (docs.sip-protocol.org → Vercel) follows after merge.

rz1989s added 2 commits May 31, 2026 09:36
rehype-mermaid's img-svg strategy renders diagrams to SVG at build time using a headless Chromium. Vercel's build image can't launch it (missing libnspr4.so and other system libs), so the build fails.

Switch to the 'pre-mermaid' strategy, which emits <pre class="mermaid"> blocks, and render them in the browser via a Starlight <Head> override. The renderer is theme-aware (MutationObserver on data-theme), view-transition-safe (astro:page-load), and lazy (mermaid loads only on pages with a diagram).

Add mermaid as a direct dependency for the client render. playwright is retained because mermaid-isomorphic imports it at module load even under pre-mermaid; it is never launched.
Pin the build to 'npm run build' so the docs:api TypeDoc step runs (Astro's framework default would skip it), and skip Playwright's browser download at install time. .vercelignore excludes the build output and the TypeDoc-generated reference dir, both regenerated during the build.
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
sip-docs Ready Ready Preview, Comment May 31, 2026 2:48am

Adding mermaid via local npm 11 (node 24) rewrote the lock file so that CI's strict 'npm ci' under npm 10 (node 20) rejects it — npm 10 resolves ws@8.21.0 as its own entry. Regenerated with npm 10 so the lock file is in sync for 'npm ci'. Follow-up: align node/npm across local, CI, and Vercel to prevent recurrence.
@rz1989s
rz1989s force-pushed the fix/vercel-mermaid-client-render branch from 8619ac3 to f233813 Compare May 31, 2026 02:46
@rz1989s
rz1989s merged commit 9e08fe2 into main May 31, 2026
3 checks passed
@rz1989s
rz1989s deleted the fix/vercel-mermaid-client-render branch May 31, 2026 02:54
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.

1 participant