Diagrams

A ```mermaid fenced block is turned into a self-contained SVG at build time — no client-side Mermaid, no headless browser. Every diagram below uses the site's own CSS tokens, so it flips with light/dark automatically, like the rest of the page. Source lives in lib/mermaid.ts; the styleguide (Style Guide) has the one-paragraph version.

TIP

Toggle View as Markdown in the header to copy the source of any diagram on this page.

Flowchart

Branches, labels, and a decision node. Directions: TD (top-down), LR (left-right), BT, RL.

content/projects content/news New .md file Where does it live? Shows in the project index Shows in the /news feed Live on push to main

Node shapes

The same graph syntax, different brackets per shape.

Markdown remark / rehype Static HTML Vercel CDN Reader

Subgraphs

Group related nodes with subgraph … end.

Build time Per request Read .md Render to SVG / HTML CDN edge Browser

Coloured edges

Diagrams are monochrome by design — they inherit the page's foreground / border tokens. To tint one connection, use linkStyle (works in flowcharts and state diagrams). Edges are numbered from 0 in source order; set stroke to a hex or a theme token (var(--destructive)) so the colour still flips with dark mode, plus an optional stroke-width.

hit miss Request In cache? Serve instantly Build, then cache

To recolour every diagram at once, edit the COLORS map in lib/mermaid.ts (e.g. give accent a colour — it drives arrowheads and XY-chart series). See How colours work at the bottom.

State diagram

[*] is the start / end. Labels after : annotate transitions.

submit changes approve Draft Review Published

Sequence diagram

->> is a solid (sync) call, -->> a dashed (return) message.

git push main run next build static HTML deploy live Browser Vercel Build

Class diagram

Fields, methods, and inheritance (<|--).

Content + title: string + order: int + render() Project NewsPost

ER diagram

Entity relationships with crow's-foot cardinality.

PROJECT (no attributes) TAG (no attributes) NEWS (no attributes) has has

XY charts

xychart-beta does bar, line, combined, and horizontal charts. Series colour comes from the theme's accent.

Bar:

Jan Feb Mar Apr May Jun 0 2 4 6 8 10 Count Posts per month

Line (smooth spline):

Jan Feb Mar Apr May Jun 0 500 1000 1500 2000 Words written

Bar + line together:

Jan Feb Mar Apr May Jun 0 2 4 6 8 Effort vs output Bar 1 Line 1

Horizontal (categories on the y-axis):

15 20 25 30 35 40 Writing Reading Code Design Time by area

How colours work

The renderer (lib/mermaid.ts) hands beautiful-mermaid a small COLORS map of CSS-variable references, not hex values:

RoleTokenUsed for
bgvar(--background)canvas (kept transparent)
fgvar(--foreground)text
line / bordervar(--border)connectors, node outlines
accentvar(--foreground)arrowheads, XY-chart series
mutedvar(--muted-foreground)secondary text
surfacevar(--muted)node fill tint

Because those are the same tokens the whole UI uses, the SVG re-themes itself in dark mode with no JavaScript. Two ways to add colour:

  1. One edgelinkStyle <index> stroke:<colour>,stroke-width:<n>px inside the diagram (see Coloured edges). Prefer var(--token) over a raw hex so it keeps flipping with the theme.
  2. All diagrams → change the COLORS map in lib/mermaid.ts. To stay dark-mode-safe, add a token (e.g. --diagram-accent) with light + dark values in app/globals.css and point accent at it, rather than hard-coding a hex.

NOTE

If a diagram fails to parse, it falls back to a plain code block instead of breaking the page — so a typo never takes the build down.