~ruther/blog

ref: b9c795d2bfcecd327f2b0ccf70ea55497b4ec09b blog/themes/poison/layouts/shortcodes/mermaid.html -rw-r--r-- 638 bytes
b9c795d2 — Rutherther chore: guix manifest 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- To automatically render mermaid diagrams -->
{{ if ne (.Page.Scratch.Get "hasMermaid") true }}
<script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';

    const lsTheme = localStorage.getItem("theme")
    const hugoTheme = document.body.classList.contains("dark-theme") ? "dark" : null
    const currTheme = lsTheme ? lsTheme : hugoTheme;
    const mermaidTheme = currTheme == "light" ? "default" : "dark"

    mermaid.initialize({theme: mermaidTheme});
</script>

{{ .Page.Scratch.Set "hasMermaid" true }}
{{ end }}
<div class="mermaid">
  {{- .Inner | safeHTML }}
</div>