I tried the code-fence style as the docs say, but it just won’t render and remains blank.
What I did:
- Created
render-codeblock-mermaid.html
in the correct dir with this content:
<div class="mermaid">
{{- .Inner | safeHTML }}
</div>
{{ .Page.Store.Set "hasMermaid" true }}
- Modified my content file
single.html
inlayouts/_default/
with:
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ if ne .Params.Type "page" }}
{{ partial "metadata.html" . }}
{{ end }}
{{ .Content }}
{{ 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 }}
{{ if .Params.categories }}
<p><strong>Related categories:</strong></p>
<ul>
{{ with .Params.categories }}
{{ range . }}
{{ $href := print (absURL "categories/") (urlize .) }}
<li><a href="{{ $href }}">{{ . }}</a></li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ if .Params.tags }}
<p><strong>Related tags:</strong></p>
<ul>
{{ with .Params.tags }}
{{ range . }}
{{ $href := print (absURL "tags/") (urlize .) }}
<li><a href="{{ $href }}">{{ . }}</a></li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ end }}
- Result = a blank white area where the diagram should be.
In the end only the short-code method is working, based on this: