← All docs

Diagram authoring rules

Rules for writing pages in this repo. They exist so the guarantees of the diagram pipeline (zero client JS, theme-adaptive SVGs, audited contrast) survive convenience later. Deviations are build failures, not style opinions.

1. Prose first — diagrams illustrate

Every diagram must be introduced and summarized by ordinary HTML text around it: a paragraph before or after stating what it shows and why it matters.

Rationale:

Test: delete every diagram from the page mentally. If the point of the page doesn’t survive in words alone, write more words before adding graphics back.

2. Author colors are raw literals

Mermaid’s parsers reject var() outright (sequence box even rejects CSS tokens). Inside fences:

3. The audit is the gate

node scripts/check-contrast.mjs must pass at 4.5:1 for every diagram, in both themes, before deploy. It composites semi-transparent fills in paint order and checks foreignObject HTML labels too. A red audit means fix the colors, not the threshold.

4. Build hygiene

After touching src/plugins/, astro.config.mjs, or anything in the markdown dependency chain:

plaintext
rm -rf dist node_modules/.astro node_modules/.vite && npm run build

Vite’s pre-bundle can serve stale plugin code that looks like a phantom bug. Also grep the build log for [ERROR]: a failed Mermaid parse emits an EMPTY page body and exits 0.

5. New diagram types

Each Mermaid diagram type ships its own color plumbing. When adding one: build once, run the leftover-literal scan plus the audit, then extend themeTokenMap / aliases until nothing mermaid-internal survives untokenized. Icon brand colors and deliberate C4 statics may stay raw — document them here when they do.