expose mermaid options in config.toml #4

This commit is contained in:
Sören Weber 2020-09-20 14:36:54 +02:00
parent b52a263979
commit 3564d9ebfa
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 9 additions and 0 deletions

View file

@ -19,6 +19,7 @@ relativeURLs = true
disableLandingPageButton = true
disableMermaid = false
customMermaidURL = "https://unpkg.com/mermaid@8.8.0/dist/mermaid.min.js"
mermaidInitialize = "{ \"securityLevel\": \"loose\", \"startOnLoad\": true }"
titleSeparator = "::"
themeVariant = "relearn"

View file

@ -74,9 +74,17 @@
{{ else }}
<script src="{{"mermaid/mermaid.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{ end }}
{{ if isset .Params "mermaidinitialize" }}
{{ $.Scratch.Set "mermaidInitialize" .Params.mermaidInitialize }}
{{ else if isset .Site.Params "mermaidinitialize" }}
{{ $.Scratch.Set "mermaidInitialize" .Site.Params.mermaidInitialize }}
{{ else }}
{{ $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }}
{{ end }}
<script>
if (mermaid) {
mermaid.startOnLoad = false;
mermaid.initialize(JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}));
}
</script>
{{ end }}