layouts: add Mermaid support

Similar to Graphviz and TikZ support.
This commit is contained in:
Bruno BELANYI 2024-07-20 17:24:21 +01:00
parent 87ef9dd38c
commit 5a233e7384
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,16 @@
<pre class="mermaid">
{{ with .Get "file" }}
{{ if eq (. | printf "%.1s") "/" }}
{{/* Absolute path are from root of site. */}}
{{ $.Scratch.Set "filepath" . }}
{{ else }}
{{/* Relative paths are from page directory. */}}
{{ $.Scratch.Set "filepath" $.Page.File.Dir }}
{{ $.Scratch.Add "filepath" . }}
{{ end }}
{{ $.Scratch.Get "filepath" | readFile }}
{{ else }}
{{.Inner}}
{{ end }}
</pre>