LoveIt/layouts/partials/assets.html
2020-04-22 01:00:51 +08:00

271 lines
No EOL
15 KiB
HTML

{{- $params := .Scratch.Get "params" -}}
{{- $cdn := .Scratch.Get "cdn" | default dict -}}
{{- $fingerprint := .Scratch.Get "fingerprint" -}}
{{- $config := (.Scratch.Get "this").config -}}
{{- /* Fork Awesome */ -}}
{{- if (.Scratch.Get "this").forkawesome -}}
{{- $options := dict "targetPath" "lib/forkawesome/fork-awesome.min.css" -}}
{{- dict "source" "lib/forkawesome/fork-awesome.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- /* iconfont */ -}}
{{- if (.Scratch.Get "this").iconfont -}}
{{- with $cdn.iconfontCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/iconfont/iconfont.css" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- end -}}
{{- /* Smooth Scroll */ -}}
{{- with $cdn.smoothScrollJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/smooth-scroll/smooth-scroll.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- /* Search */ -}}
{{- if .Site.Params.search.enable -}}
{{- with $cdn.autocompleteJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/autocomplete/autocomplete.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $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 -}}
{{- with $cdn.lunrJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/lunr/lunr.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- 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" -}}
{{- with $cdn.algoliasearchJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/algoliasearch/algoliasearch-lite.umd.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $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 */ -}}
{{- with $cdn.lazysizesJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/lazysizes/lazysizes.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- /* lightgallery.js */ -}}
{{- if $params.lightgallery -}}
{{- with $cdn.lightgalleryCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/lightgallery/lightgallery.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- with $cdn.lightgalleryJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/lightgallery/lightgallery.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- with $cdn.lightgalleryThumbnailJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/lightgallery/lg-thumbnail.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- with $cdn.lightgalleryZoomJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/lightgallery/lg-zoom.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $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 -}}
{{- /* clipboard.js */ -}}
{{- if ne $params.copycode false -}}
{{- with $cdn.clipboardJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/clipboard/clipboard.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $config = T "copyToClipboard" | dict "title" | dict "clipboard" | merge $config -}}
{{- end -}}
{{- /* Sharer.js */ -}}
{{- if $params.share.enable -}}
{{- with $cdn.sharerJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/sharer/sharer.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- end -}}
{{- /* TypeIt */ -}}
{{- with (.Scratch.Get "this").typeitMap -}}
{{- with $cdn.typeitJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/typeit/typeit.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $typeitConfig := slice -}}
{{- range $key, $val := . -}}
{{- $typeitConfig = $typeitConfig | append (slice $val) -}}
{{- end -}}
{{- $config = dict "typeit" $typeitConfig | merge $config -}}
{{- end -}}
{{- /* KaTeX */ -}}
{{- if $params.math.enable -}}
{{- with $cdn.katexCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/katex.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- with $cdn.katexJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/katex.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- with $cdn.katexAutoRenderJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/auto-render.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $math := $params.math -}}
{{- if $math.copyTex -}}
{{- with $cdn.katexCopyTexCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/copy-tex.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- with $cdn.katexCopyTexJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/copy-tex.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- end -}}
{{- if $math.mhchem -}}
{{- with $cdn.katexMhchemJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/katex/mhchem.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- 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 -}}
{{- with $cdn.mermaidJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/mermaid/mermaid.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- $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 -}}
{{- with $cdn.echartsJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/echarts/echarts.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- with $cdn.echartsMacaronsJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/echarts/macarons.js" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- end -}}
{{- /* Mapbox GL */ -}}
{{- if (.Scratch.Get "this").mapbox -}}
{{- with $cdn.mapboxGLCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- with $cdn.mapboxGLJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- 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 */ -}}
{{- with $cdn.aplayerCSS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- else -}}
{{- dict "source" "lib/aplayer/APlayer.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
{{- end -}}
{{- $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" -}}
{{- with $cdn.aplayerJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/aplayer/APlayer.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- /* MetingJS */ -}}
{{- with $cdn.metingJS -}}
{{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- else -}}
{{- dict "source" "lib/meting/Meting.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- end -}}
{{- 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 -}}
<script type="text/javascript">
window.config = {{ $config | jsonify | safeJS }};
</script>
{{- /* 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 -}}
{{- /* Google analytics async */ -}}
{{- if eq hugo.Environment "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }}
{{- partial "plugin/analytics/fathom" . -}}
{{ end }}
{{- end -}}