Add support for Mermaid diagrams

Per instructions from Hugo:
https://gohugo.io/content-management/diagrams/#mermaid-diagrams

The styling could probably be updated to be more in line with the rest
of the docs, but this already looks better to me than the goat ASCII
diagrams Hugo supports out of the box.

Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
Nic Cope 2023-10-27 15:42:52 -07:00
parent 2e993500cb
commit cb1f9d2f9c
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,4 @@
<pre class="mermaid">
{{- .Inner | safeHTML }}
</pre>
{{ .Page.Store.Set "hasMermaid" true }}

View File

@ -75,3 +75,10 @@
</div>
</main>
</div>
{{ if .Page.Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
{{ end }}