2023-08-12 22:48:41 +01:00
|
|
|
{{ $jsTheme := resources.Get "js/theme.js" }}
|
|
|
|
{{ $jsMenu := resources.Get "js/menu.js" }}
|
|
|
|
{{ $jsCodeCopy := resources.Get "js/code-copy.js" }}
|
2023-08-13 22:18:20 +01:00
|
|
|
{{ $jsTabs := resources.Get "js/tabs.js" }}
|
|
|
|
{{ $jsLang := resources.Get "js/lang.js" }}
|
2023-07-30 22:18:28 +01:00
|
|
|
|
2023-08-13 22:18:20 +01:00
|
|
|
{{ $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang | resources.Concat "js/main.js" }}
|
2023-08-12 22:48:41 +01:00
|
|
|
{{ if hugo.IsProduction }}
|
|
|
|
{{ $scripts = $scripts | minify | fingerprint }}
|
2023-08-02 21:24:52 +01:00
|
|
|
{{ end }}
|
2023-08-12 22:48:41 +01:00
|
|
|
<script defer src="{{ $scripts.RelPermalink }}" integrity="{{ $scripts.Data.Integrity }}"></script>
|
2023-08-02 21:24:52 +01:00
|
|
|
|
2023-08-12 22:48:41 +01:00
|
|
|
{{/* FlexSearch */}}
|
|
|
|
{{- if not site.Params.search.disabled -}}
|
|
|
|
{{ $jsSearchScript := printf "%s.search.js" .Language.Lang }}
|
|
|
|
{{ $jsSearch := resources.Get "js/flexsearch.js" | resources.ExecuteAsTemplate $jsSearchScript . }}
|
|
|
|
{{ if hugo.IsProduction }}
|
|
|
|
{{ $jsSearch = $jsSearch | minify | fingerprint }}
|
|
|
|
{{ end }}
|
|
|
|
{{ $flexSearchJS := resources.Get "vendor/flexsearch/flexsearch.bundle.min.js" | fingerprint }}
|
|
|
|
<script defer src="{{ $flexSearchJS.RelPermalink }}" integrity="{{ $flexSearchJS.Data.Integrity }}"></script>
|
|
|
|
<script defer src="{{ $jsSearch.RelPermalink }}" integrity="{{ $jsSearch.Data.Integrity }}"></script>
|
|
|
|
{{- end -}}
|
2023-08-06 15:23:37 +01:00
|
|
|
|
2023-08-12 22:48:41 +01:00
|
|
|
{{/* Mermaid */}}
|
|
|
|
{{ if .Page.Store.Get "hasMermaid" -}}
|
|
|
|
{{ $mermaidJS := resources.Get "vendor/mermaid/mermaid.min.js" | fingerprint }}
|
|
|
|
<script defer src="{{ $mermaidJS.RelPermalink }}" integrity="{{ $mermaidJS.Data.Integrity }}"></script>
|
|
|
|
<script>
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
const theme = document.documentElement.classList.contains("dark") ? "dark" : "default";
|
|
|
|
mermaid.initialize({ startOnLoad: true, theme: theme });
|
|
|
|
});
|
|
|
|
</script>
|
2023-08-06 01:06:32 +01:00
|
|
|
{{ end }}
|
2023-08-04 01:11:31 +01:00
|
|
|
|
2023-08-12 22:48:41 +01:00
|
|
|
{{/* KaTex */}}
|
|
|
|
{{ if and (not site.Params.math.disabled) .Page.Params.math }}
|
|
|
|
{{ $katexCSS := resources.Get "vendor/katex/katex.min.css" | fingerprint }}
|
|
|
|
{{ $katexJS := resources.Get "vendor/katex/katex.min.js" | fingerprint }}
|
|
|
|
{{ $katexAutoRenderJS := resources.Get "vendor/katex/auto-render.min.js" | fingerprint }}
|
|
|
|
<link type="text/css" rel="stylesheet" href="{{ $katexCSS.RelPermalink }}" integrity="{{ $katexCSS.Data.Integrity }}" />
|
|
|
|
<script defer src="{{ $katexJS.RelPermalink }}" integrity="{{ $katexJS.Data.Integrity }}"></script>
|
|
|
|
<script defer src="{{ $katexAutoRenderJS.RelPermalink }}" integrity="{{ $katexAutoRenderJS.Data.Integrity }}"></script>
|
|
|
|
{{ $katexFonts := resources.Match "vendor/katex/fonts/*" }}
|
|
|
|
{{ range $katexFonts }}
|
|
|
|
{{ .Publish }}
|
|
|
|
{{ end }}
|
2023-07-30 22:18:28 +01:00
|
|
|
<script>
|
2023-08-12 22:48:41 +01:00
|
|
|
// TODO: make render options configurable
|
2023-07-30 22:18:28 +01:00
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
renderMathInElement(document.body, {
|
|
|
|
delimiters: [
|
|
|
|
{ left: "$$", right: "$$", display: true },
|
|
|
|
{ left: "$", right: "$", display: false },
|
|
|
|
{ left: "\\(", right: "\\)", display: false },
|
|
|
|
{ left: "\\[", right: "\\]", display: true },
|
|
|
|
],
|
|
|
|
throwOnError: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{{ end }}
|