2023-08-14 21:56:26 +01:00
|
|
|
{{- $jsTheme := resources.Get "js/theme.js" -}}
|
|
|
|
{{- $jsMenu := resources.Get "js/menu.js" -}}
|
|
|
|
{{- $jsTabs := resources.Get "js/tabs.js" -}}
|
|
|
|
{{- $jsLang := resources.Get "js/lang.js" -}}
|
2023-08-16 15:11:03 +01:00
|
|
|
{{- $jsCodeCopy := resources.Get "js/code-copy.js" -}}
|
|
|
|
{{- $jsFileTree := resources.Get "js/filetree.js" -}}
|
2023-07-30 22:18:28 +01:00
|
|
|
|
2023-08-16 15:11:03 +01:00
|
|
|
{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsFileTree | resources.Concat "js/main.js" -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- if hugo.IsProduction -}}
|
|
|
|
{{- $scripts = $scripts | minify | fingerprint -}}
|
|
|
|
{{- 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 -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- $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 -}}
|
2023-08-12 22:48:41 +01:00
|
|
|
<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 */}}
|
2023-08-17 23:31:04 +01:00
|
|
|
{{/* FIXME: need to investigate .Page.Store hasMermaid is set for homepage */}}
|
|
|
|
{{- if and (.Page.Store.Get "hasMermaid") (not .Page.IsHome) -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- $mermaidJS := resources.Get "vendor/mermaid/mermaid.min.js" | fingerprint -}}
|
2023-08-12 22:48:41 +01:00
|
|
|
<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-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
2023-08-04 01:11:31 +01:00
|
|
|
|
2023-08-12 22:48:41 +01:00
|
|
|
{{/* KaTex */}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- 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 -}}
|
2023-08-19 00:32:10 +01:00
|
|
|
{{- $mhchemJS := resources.Get "vendor/katex/mhchem.min.js" | fingerprint -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- $katexAutoRenderJS := resources.Get "vendor/katex/auto-render.min.js" | fingerprint -}}
|
2023-08-12 22:48:41 +01:00
|
|
|
<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>
|
2023-08-19 00:32:10 +01:00
|
|
|
<script defer src="{{ $mhchemJS.RelPermalink }}" integrity="{{ $mhchemJS.Data.Integrity }}"></script>
|
2023-08-12 22:48:41 +01:00
|
|
|
{{ $katexFonts := resources.Match "vendor/katex/fonts/*" }}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- range $katexFonts -}}
|
2023-08-12 22:48:41 +01:00
|
|
|
{{ .Publish }}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- 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 }}
|