portails/layouts/partials/footer/script-footer.html

105 lines
4.3 KiB
HTML

{{ $indexTemplate := resources.Get "js/index.js" -}}
{{ $index := $indexTemplate | resources.ExecuteAsTemplate "index.js" . -}}
{{ $bs := resources.Get "js/bootstrap.js" -}}
{{ $bs := $bs | js.Build -}}
{{ $highlight := resources.Get "js/highlight.js" -}}
{{ $highlight := $highlight | js.Build -}}
{{ $katex := resources.Get "js/vendor/katex/dist/katex.js" -}}
{{ $katexAutoRender := resources.Get "js/vendor/katex/dist/contrib/auto-render.js" -}}
{{ $mermaid := resources.Get "js/vendor/mermaid/dist/mermaid.min.js" -}}
{{ $app := resources.Get "js/app.js" -}}
{{ $slice := slice $app -}}
{{ if .Site.Params.options.lazySizes -}}
{{ $lazySizes := resources.Get "js/lazysizes.js" -}}
{{ $lazySizes := $lazySizes | js.Build -}}
{{ $slice = $slice | append $lazySizes -}}
{{ end -}}
{{ if .Site.Params.options.clipBoard -}}
{{ $clipBoard := resources.Get "js/clipboard.js" -}}
{{ $clipBoard := $clipBoard | js.Build -}}
{{ $slice = $slice | append $clipBoard -}}
{{ end -}}
{{ if .Site.Params.options.instantPage -}}
{{ $instantPage := resources.Get "js/instant.page.js" -}}
{{ $instantPage := $instantPage | js.Build -}}
{{ $slice = $slice | append $instantPage -}}
{{ end -}}
{{ if .Site.Params.options.flexSearch -}}
{{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}}
{{ $slice = $slice | append $flexSearch -}}
{{ end -}}
{{ if .Site.Params.options.darkMode -}}
{{ $darkMode := resources.Get "js/darkmode.js" -}}
{{ $darkMode := $darkMode | js.Build -}}
{{ $slice = $slice | append $darkMode -}}
{{ end -}}
{{ if .Site.Params.options.kaTex -}}
{{ $katexConfig := resources.Get "js/katex.js" -}}
{{ $katexConfig := $katexConfig | js.Build -}}
{{ $slice = $slice | append $katexConfig -}}
{{ end -}}
{{ if .Site.Params.options.mermaid -}}
{{ $mermaidConfig := resources.Get "js/mermaid.js" -}}
{{ $mermaidConfig := $mermaidConfig | js.Build -}}
{{ $slice = $slice | append $mermaidConfig -}}
{{ end -}}
{{ $js := $slice | resources.Concat "main.js" -}}
{{ if eq (hugo.Environment) "development" -}}
{{ if .Site.Params.options.bootStrapJs -}}
<script src="{{ $bs.RelPermalink }}" defer></script>
{{ end -}}
{{ if .Site.Params.options.highLight -}}
<script src="{{ $highlight.RelPermalink }}" defer></script>
{{ end -}}
{{ if .Site.Params.options.kaTex -}}
<script src="{{ $katex.RelPermalink }}" defer></script>
<script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script>
{{ end -}}
{{ if .Site.Params.options.mermaid -}}
<script src="{{ $mermaid.RelPermalink }}" defer></script>
{{ end -}}
<script src="{{ $js.RelPermalink }}" defer></script>
{{ if .Site.Params.options.flexSearch -}}
<script src="{{ $index.RelPermalink }}" defer></script>
{{ end -}}
{{ else -}}
{{ $js := $js | minify | fingerprint "sha512" -}}
{{ $index := $index | minify | fingerprint "sha512" -}}
{{ $bs := $bs | minify | fingerprint "sha512" -}}
{{ $highlight := $highlight | minify | fingerprint "sha512" -}}
{{ $katex := $katex | minify | fingerprint "sha512" -}}
{{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}}
{{ $mermaid := $mermaid | minify | fingerprint "sha512" -}}
{{ if .Site.Params.options.bootStrapJs -}}
<script src="{{ $bs.RelPermalink }}" integrity="{{ $bs.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ if .Site.Params.options.highLight -}}
<script src="{{ $highlight.RelPermalink }}" integrity="{{ $highlight.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ if .Site.Params.options.kaTex -}}
<script src="{{ $katex.RelPermalink }}" integrity="{{ $katex.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ if .Site.Params.options.mermaid -}}
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ if .Site.Params.options.flexSearch -}}
<script src="{{ $index.RelPermalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ end -}}