hugo-relie/themes/hello-friend-ng/layouts/partials/javascript.html

37 lines
No EOL
1.2 KiB
HTML

{{ $main := resources.Get "js/main.js" }}
{{ $menu := resources.Get "js/menu.js" }}
{{ $prism := resources.Get "js/prism.js" }}
{{ $secureJS := slice $main $menu $prism | resources.Concat "bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
<script type="text/javascript" src="{{ $secureJS.RelPermalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{ range $val := $.Site.Params.customJS }}
{{ if gt (len $val) 0 }}
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}
{{ if .Page.Store.Get "hasMermaid" }}
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs";
const settings = localStorage.getItem("theme") === "dark" ?
{
startOnLoad: true,
theme: "dark",
darkMode: true,
themeVariables: {
tertiaryColor: "#dee3ed"
}
}
:
{
startOnLoad: true,
theme: "base",
darkMode: false,
themeVariables: {
tertiaryColor: "#dee3ed"
}
}
;
mermaid.initialize(settings);
</script>
{{ end }}