Use a Hugo render hook to convert mermaid code blocks into <pre> tags, and a client-side check to dynamically load the vendored mermaid.min.js only on pages that contain mermaid diagrams. The library is vendored locally via vendor-mermaid.sh (to be run with datalad run) instead of loaded from a CDN, so the site does not depend on external services.
4 lines
110 B
HTML
4 lines
110 B
HTML
<pre class="mermaid">
|
|
{{- .Inner | htmlEscape | safeHTML }}
|
|
</pre>
|
|
{{- .Page.Store.Set "hasMermaid" true }}
|