{{- $params := .Scratch.Get "params" -}} {{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} {{- $config := (.Scratch.Get "this").config -}} {{- /* Smooth Scroll */ -}} {{- $source := $cdn.smoothScrollJS | default "lib/smooth-scroll/smooth-scroll.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- /* Search */ -}} {{- if .Site.Params.search.enable -}} {{- $source := $cdn.autocompleteJS | default "lib/autocomplete/autocomplete.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $searchConfig := dict "noResultsFound" (T "noResultsFound") -}} {{- if eq .Site.Params.search.type "lunr" -}} {{- with .Site.Home.OutputFormats.Get "json" -}} {{- $searchConfig = dict "type" "lunr" "lunrIndexURL" .RelPermalink | merge $searchConfig -}} {{- end -}} {{- $source := $cdn.lunrJS | default "lib/lunr/lunr.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- if ne .Language.Lang "en" -}} {{- $searchConfig = T "lunrLanguageCode" | dict "lunrLanguageCode" | merge $searchConfig -}} {{- if eq .Language.Lang "zh-cn" -}} {{- $searchConfig = dict "lunrSegmentitURL" (resources.Get "lib/lunr/lunr.segmentit.js").RelPermalink | merge $searchConfig -}} {{- end -}} {{- dict "source" "lib/lunr/lunr.stemmer.support.js" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- dict "source" (T "lunrLanguageLib") "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- else if eq .Site.Params.search.type "algolia" -}} {{- $source := $cdn.algoliasearchJS | default "lib/algoliasearch/algoliasearch-lite.umd.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $searchConfig = dict "type" "algolia" "algoliaIndex" .Site.Params.search.algolia.index "algoliaAppID" .Site.Params.search.algolia.appID "algoliaSearchKey" .Site.Params.search.algolia.searchKey | merge $searchConfig -}} {{- end -}} {{- $config = dict "search" $searchConfig | merge $config -}} {{- end -}} {{- /* lazysizes */ -}} {{- $source := $cdn.lazysizesJS | default "lib/lazysizes/lazysizes.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- /* lightgallery.js */ -}} {{- if $params.lightgallery -}} {{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/lightgallery.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/lg-thumbnail.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $source := $cdn.lightgalleryZoomJS | default "lib/lightgallery/lg-zoom.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $lightGalleryConfig := dict "selector" ".lightgallery" "speed" 400 "hideBarsDelay" 2000 "thumbnail" true "exThumbImage" "data-thumbnail" "thumbWidth" 80 "thumbContHeight" 80 "actualSize" false -}} {{- $config = dict "lightGallery" $lightGalleryConfig | merge $config -}} {{- end -}} {{- $code := $params.code | default dict -}} {{- $config = cond (ne $code.maxShownLines nil) $code.maxShownLines 10 | dict "maxShownLines" | dict "code" | merge $config -}} {{- /* clipboard.js */ -}} {{- if ne $code.copy false -}} {{- $source := $cdn.clipboardJS | default "lib/clipboard/clipboard.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $config = T "copyToClipboard" | dict "copyTitle" | dict "code" | merge $config -}} {{- end -}} {{- /* Sharer.js */ -}} {{- if $params.share.enable -}} {{- $source := $cdn.sharerJS | default "lib/sharer/sharer.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* TypeIt */ -}} {{- with (.Scratch.Get "this").typeitMap -}} {{- $source := $cdn.typeitJS | default "lib/typeit/typeit.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $typeitConfig := slice -}} {{- range $key, $val := . -}} {{- $typeitConfig = $typeitConfig | append (slice $val) -}} {{- end -}} {{- $config = dict "typeit" $typeitConfig | merge $config -}} {{- end -}} {{- /* KaTeX */ -}} {{- if $params.math.enable -}} {{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.katexJS | default "lib/katex/katex.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $source := $cdn.katexAutoRenderJS | default "lib/katex/auto-render.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $math := $params.math -}} {{- if $math.copyTex -}} {{- $source := $cdn.katexCopyTexCSS | default "lib/katex/copy-tex.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.katexCopyTexJS | default "lib/katex/copy-tex.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- if $math.mhchem -}} {{- $source := $cdn.katexMhchemJS | default "lib/katex/mhchem.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- $mathConfig := dict "strict" false -}} {{- $delimiters := slice (dict "left" "$$" "right" "$$" "display" true) (dict "left" "\\[" "right" "\\]" "display" true) -}} {{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}} {{- $delimiters = $delimiters | append (dict "left" $math.blockLeftDelimiter "right" $math.blockRightDelimiter "display" true) -}} {{- end -}} {{- $delimiters = $delimiters | append (dict "left" "$" "right" "$" "display" false) (dict "left" "\\(" "right" "\\)" "display" false) -}} {{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}} {{- $delimiters = $delimiters | append (dict "left" $math.inlineRightDelimiter "right" $math.inlineRightDelimiter "display" false) -}} {{- end -}} {{- $mathConfig = dict "delimiters" $delimiters | merge $mathConfig -}} {{- $config = dict "math" $mathConfig | merge $config -}} {{- end -}} {{- /* mermaid */ -}} {{- if (.Scratch.Get "this").mermaid -}} {{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" -}} {{- dict "source" "lib/mermaid/mermaid.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- /* ECharts */ -}} {{- if (.Scratch.Get "this").echarts -}} {{- $source := $cdn.echartsJS | default "lib/echarts/echarts.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $source := $cdn.echartsMacaronsJS | default "lib/echarts/macarons.js" -}} {{- dict "source" $source "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* Mapbox GL */ -}} {{- if (.Scratch.Get "this").mapbox -}} {{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- dict "source" "lib/mapbox-gl/mapbox-gl-language.js" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $config = dict "accessToken" $params.mapbox.accessToken "RTLTextPlugin" "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js" | dict "mapbox" | merge $config -}} {{- end -}} {{- /* Music */ -}} {{- if (.Scratch.Get "this").music -}} {{- /* APlayer */ -}} {{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $options := dict "targetPath" "lib/aplayer/dark.min.css" -}} {{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.aplayerJS | default "lib/aplayer/APlayer.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- /* MetingJS */ -}} {{- $source := $cdn.metingJS | default "lib/meting/Meting.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* Theme script */ -}} {{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}} {{- range (.Scratch.Get "this").stylesheet -}} {{- partial "plugin/stylesheet.html" . -}} {{- end -}} {{- /* Polyfill.io */ -}} {{- partial "plugin/script.html" (dict "source" "https://polyfill.io/v3/polyfill.min.js?features=Element.prototype.closest%2CrequestAnimationFrame%2CCustomEvent%2CPromise%2CObject.entries%2CObject.assign%2CObject.values%2Cfetch%2CElement.prototype.after") -}} {{- range (.Scratch.Get "this").script -}} {{- partial "plugin/script.html" . -}} {{- end -}} {{- with .Scratch.Get "analytics" -}} {{- partial "plugin/analytics.html" . -}} {{- end -}}