Integrate mermaid

This commit is contained in:
Raphaël Lemaitre 2023-11-18 23:56:46 +01:00
parent aa2825a2a7
commit d4e86b557b
No known key found for this signature in database
GPG key ID: 90C3CD1F68B07B31
2 changed files with 29 additions and 0 deletions

View file

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

View file

@ -9,3 +9,28 @@
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}
{{ if .Page.Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
const settings = localStorage.getItem('theme') === 'dark' ?
{
startOnLoad: true,
theme: 'dark',
darkMode: true,
themeVariables: {
tertiaryColor: '#dee3ed'
}
}
:
{
startOnLoad: true,
theme: 'base',
darkMode: false,
themeVariables: {
tertiaryColor: '#dee3ed'
}
}
;
mermaid.initialize(settings);
</script>
{{ end }}