{{/* Header */}} {{ $header_js := resources.Get "js/header.js" }} {{- if hugo.IsProduction -}} {{ $header_js = $header_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}} {{- else -}} {{ $header_js = $header_js | js.Build -}} {{- end -}} {{/* Zooming.js */}} {{ if (.Scratch.Get "params").enable_zooming_js }} {{ $zooming_js := resources.Get "js/zooming.js" }} {{- if hugo.IsProduction -}} {{ $zooming_js = $zooming_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}} {{- else -}} {{ $zooming_js = $zooming_js | js.Build -}} {{- end -}} {{ end }} {{/* MathJax */}} {{ if (.Scratch.Get "params").math }} {{ $math_js := resources.Get "js/math.js" }} {{- if hugo.IsProduction -}} {{ $math_js = $math_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}} {{- else -}} {{ $math_js = $math_js | js.Build -}} {{- end -}} {{ end }} {{/* Load script for only page contain codeblock */}} {{ if (findRE "
{{ end }}
{{ else if eq (.Scratch.Get "params").syntax_highlight.lib "prism.js" }}
{{ $prism_js := slice (resources.Get "lib/js/prism-v1.29.0.min.js") }}
{{ $enable_line_no := (.Scratch.Get "params").syntax_highlight.prism.enable_line_no | default true }}
{{ if $enable_line_no }}
{{ $prism_js = $prism_js | append (resources.Get "lib/js/prism-line-numbers-v1.29.0.min.js") }}
{{ end }}
{{ $enable_code_copy := (.Scratch.Get "params").syntax_highlight.prism.enable_code_copy | default true }}
{{ if $enable_code_copy }}
{{ $prism_js = $prism_js | append (resources.Get "lib/js/prism-copy-to-clipboard-v1.29.0.min.js") }}
{{ end }}
{{ $prism_js = $prism_js | append (resources.Get "js/prism-autoloader.js") | append (resources.Get "js/prism.js") | resources.Concat "js/prism.js" }}
{{- if hugo.IsProduction -}}
{{ $prism_js = $prism_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $prism_js = $prism_js | js.Build -}}
{{- end -}}
{{ end }}
{{ end }}
{{ if (.Scratch.Get "params").enable_site_search }}
{{ $target_path := printf "js/search-%s.js" .Site.LanguageCode }}
{{ $index_url := "index.json" | absLangURL }}
{{ $build_opts := dict "targetPath" $target_path "params" (dict "index_url" $index_url) }}
{{ $search_js := resources.Get "js/search.js" | js.Build $build_opts }}
{{- if hugo.IsProduction -}}
{{ $search_js = $search_js | js.Build (merge $build_opts (dict "minify" true)) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $search_js = $search_js | js.Build $build_opts -}}
{{- end -}}
{{ end }}
{{/* Load highlighter for emgithub */}}
{{ if .HasShortcode "emgithub" }}
{{ $js := slice (resources.Get "lib/js/prism-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "lib/js/prism-line-numbers-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "lib/js/prism-copy-to-clipboard-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "js/prism-autoloader.js") }}
{{ $js = $js | resources.Concat "js/emgithub-prism.js" }}
{{- if hugo.IsProduction -}}
{{ $js = $js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $js = $js | js.Build }}
{{- end -}}
{{ end }}