{{ $origin := cond (eq .Site.Params.self_host true) "basic" "cors" }} {{ $data := index .Site.Data.origin $origin }} {{ $is_home := false }} {{ if or (eq .RelPermalink "/") (eq .RelPermalink (relLangURL "/")) }} {{ $is_home = true }} {{ end }} {{- $jsOpts := dict "target" "es2015" "minify" (eq hugo.Environment "production") -}} {{ $urls := slice }} {{ $urls = $urls | append $data.search.js }} {{ if or (eq .Type "post") (eq .Layout "page") $is_home }} {{ with $data.lazyPolyfill.js }} {{ $urls = $urls | append . }} {{ end }} {{ if not $is_home }} {{ with $data.glightbox.js }} {{ $urls = $urls | append . }} {{ end }} {{ with $data.clipboard.js }} {{ $urls = $urls | append . }} {{ end }} {{ end }} {{ end }} {{ if or $is_home (eq .Type "post") (eq .Layout "archives") (eq .Type "categories") (eq .Type "tags") }} {{ $locale := strings.TrimSuffix (path.Ext .Lang) .Lang }} {{ with $data.dayjs.js.common }} {{ $urls = $urls | append . }} {{ end }} {{ with replace $data.dayjs.js.locale ":LOCALE" $locale }} {{ $urls = $urls | append . }} {{ end }} {{ with $data.dayjs.js.relativeTime }} {{ $urls = $urls | append . }} {{ end }} {{ with $data.dayjs.js.localizedFormat }} {{ $urls = $urls | append . }} {{ end }} {{ end }} {{ if or (strings.Contains .Content " {{ end }} {{ $js := "commons" }} {{ if $is_home }} {{ $js = "home" }} {{ else if eq .Layout "categories" }} {{ $js = "categories" }} {{ else if eq .Type "post" }} {{ $js = "post" }} {{ else if eq .Layout "page" }} {{ $js = "page" }} {{ else if or (eq .Layout "archives") (eq .Type "categories") (eq .Type "tags") }} {{ $js = "misc" }} {{ end }} {{- $script := resources.Get (printf "js/%s.js" $js) | js.Build $jsOpts -}} {{ if .Params.math }} {{ $mathjaxConfig := resources.Get "js/data/mathjax.js" | minify | fingerprint }} {{ $mathjax := (index site.Data.origin site.Params.cdn).mathjax.js }} {{ end }} {{ if eq .Type "post" }} {{ $provider := site.Params.pageviews.provider }} {{ if and $provider (ne $provider "") }} {{ if eq $provider "goatcounter" }} {{ if and site.Params.analytics.goatcounter.id (ne site.Params.analytics.goatcounter.id "") }} {{ partial (printf "pageviews/%s.html" $provider) . }} {{ end }} {{ end }} {{ end }} {{ end }}