mermaid: only load javascript if necessary #95

This commit is contained in:
Sören Weber 2021-10-30 20:31:52 +02:00
parent 22180dcf07
commit 3446aa4230
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 9 additions and 1 deletions

View file

@ -1,4 +1,9 @@
+++ +++
title = "Relearrrn Theme fer Cap'n Hugo" title = "Relearrrn Theme fer Cap'n Hugo"
+++ +++
{{% notice warning %}}
Arrr fello pirrates, be awarrre some featurrres may not work fer us in this trrranslat'n. Like table of contents orrr seeing Merrrmaids.
{{% /notice %}}
{{< piratify >}} {{< piratify >}}

View file

@ -25,6 +25,7 @@
<script src="{{"js/jquery.svg.pan.zoom.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/jquery.svg.pan.zoom.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/featherlight.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/featherlight.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/modernizr.custom-3.6.0.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/modernizr.custom-3.6.0.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{- if .HasShortcode "mermaid" }}
{{- if (or (and (ne .Params.disableMermaid nil) (not .Params.disableMermaid)) (not .Site.Params.disableMermaid)) }} {{- if (or (and (ne .Params.disableMermaid nil) (not .Params.disableMermaid)) (not .Site.Params.disableMermaid)) }}
{{- if isset .Params "custommermaidurl" }} {{- if isset .Params "custommermaidurl" }}
<script src="{{ .Params.customMermaidURL }}"></script> <script src="{{ .Params.customMermaidURL }}"></script>
@ -40,11 +41,13 @@
{{- else }} {{- else }}
{{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }} {{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }}
{{- end }} {{- end }}
<script>
>
if (typeof mermaid != 'undefined') { if (typeof mermaid != 'undefined') {
mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) ); mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) );
} }
</script> </script>
{{- end }}
{{- end }} {{- end }}
<script src="{{"js/relearn.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/relearn.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{- partial "custom-footer.html" . }} {{- partial "custom-footer.html" . }}