layouts: add Mermaid support
Similar to Graphviz and TikZ support.
This commit is contained in:
parent
87ef9dd38c
commit
5a233e7384
|
@ -9,6 +9,7 @@ categories:
|
||||||
favorite: false
|
favorite: false
|
||||||
tikz: true
|
tikz: true
|
||||||
graphviz: true
|
graphviz: true
|
||||||
|
mermaid: true
|
||||||
---
|
---
|
||||||
|
|
||||||
## Test post please ignore
|
## Test post please ignore
|
||||||
|
@ -51,6 +52,19 @@ echo hello world | cut -d' ' -f 1
|
||||||
}
|
}
|
||||||
{{% /graphviz %}}
|
{{% /graphviz %}}
|
||||||
|
|
||||||
|
### Mermaid support
|
||||||
|
|
||||||
|
{{% mermaid %}}
|
||||||
|
graph TD
|
||||||
|
A[Enter Chart Definition] --> B(Preview)
|
||||||
|
B --> C{decide}
|
||||||
|
C --> D[Keep]
|
||||||
|
C --> E[Edit Definition]
|
||||||
|
E --> B
|
||||||
|
D --> F[Save Image and Code]
|
||||||
|
F --> B
|
||||||
|
{{% /graphviz %}}
|
||||||
|
|
||||||
### Spoilers
|
### Spoilers
|
||||||
|
|
||||||
{{% spoiler "Don't open me" %}}
|
{{% spoiler "Don't open me" %}}
|
||||||
|
|
|
@ -20,6 +20,13 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<!-- Mermaid support -->
|
||||||
|
{{ if (.Params.mermaid) }}
|
||||||
|
<script type="module" async>
|
||||||
|
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.esm.min.mjs";
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
|
{{ end }}
|
||||||
{{ with .OutputFormats.Get "atom" -}}
|
{{ with .OutputFormats.Get "atom" -}}
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
16
layouts/shortcodes/mermaid.html
Normal file
16
layouts/shortcodes/mermaid.html
Normal 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>
|
Loading…
Reference in a new issue