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

37 lines
1.2 KiB
HTML
Raw Normal View History

2023-06-19 11:40:17 +00:00
{{ $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 }}
2023-12-19 17:43:45 +00:00
{{ 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 }}