feat(site): mermaid diagram rendering + real footnotes in the cross-build matrix#487
Merged
Conversation
…land
@void/md has no mermaid support, so the cross-build decision tree and the
understanding-lifetime flowcharts SSR'd as plain highlighted code blocks.
Add a MermaidBlocks island ('load' in all three docs layout entries) that
renders null and, only when a page actually contains a language-mermaid
fence, lazy-imports mermaid (securityLevel strict, suppressErrorRendering)
and swaps each fence for the rendered SVG. The fence stays in the DOM
(hidden) as the re-render source and as the fallback on render failure.
Diagrams re-render on theme flips via a MutationObserver on the html
data-theme attribute, matching the site's dual .dark/data-theme signal.
Pages without diagrams only fetch the 1.2 KB gzip island chunk.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…de fence Two adversarial-review findings: - Remount idempotency: mounting over preserved DOM no longer stacks a second .mermaid-diagram host — the scan adopts an existing adjacent host, and the effect cleanup now removes owned hosts and restores each fence's pre-island inline display (remembered on the wrapper via data-mermaid-display) instead of only disconnecting the observer. - Failure fallback: a per-block render failure now clears that block's host and reveals the original code fence, so a theme-toggle re-render failure can no longer leave a stale wrong-theme SVG on screen. Applied consistently for first renders and re-renders; other blocks are unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #486, fixing two rendering gaps it exposed:
Mermaid diagrams
The site never rendered ```mermaid fences —
@void/mdhas no mermaid support, so the cross-build decision tree (and the pre-existing diagrams on understanding-lifetime) displayed as raw code.MermaidBlocksdocs island (with { island: 'load' }in the en/cn/pt-BR docs layouts): SSR keeps the code fence as fallback; on pages that contain mermaid fences it lazy-importsmermaid, renders each fence to SVG, and hides the fence.html[data-theme]toggle (MutationObserver).Real footnotes in the decision matrix
@void/mdbundlesmarkdown-it-footnote, but the matrix "footnotes" were plain unicode superscripts with a manual Notes list. They are now real[^1]–[^4]refs/definitions in all three locales: clickable superscripts in the table cells, backlinked footnote section, styled by the existingprose.cssrules (same convention as /docs/deep-dive/native-module). Definition text is unchanged.🤖 Generated with Claude Code