LoveIt/layouts/partials/script.html

245 lines
8.5 KiB
HTML
Raw Normal View History

2020-02-24 10:00:39 +01:00
{{- $scratch := .Scratch.Get "scratch" -}}
{{- $CDN := $scratch.Get "CDN" -}}
2020-02-14 14:09:21 +01:00
{{- /* Fork Awesome */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "forkawesome" -}}
{{- slice "lib/forkawesome/fork-awesome.scss" | $scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- /* iconfont */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "iconfont" -}}
{{- slice "lib/iconfont/iconfont.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- /* Smooth Scroll */ -}}
{{- with $CDN.smoothScrollJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/smooth-scroll/smooth-scroll.polyfills.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- /* Sharer.js */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "share" -}}
{{- with $CDN.sharerJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/sharer/sharer.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- /* lazysizes */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "lazysizes" -}}
{{- with $CDN.lazysizesJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
{{- with $CDN.lazysizesNativeLoadingJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/lazysizes/ls.native-loading.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
{{- end -}}
{{- /* lightgallery.js */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "lightgallery" -}}
{{- with $CDN.lightgalleryCSS -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "lib/lightgallery/lightgallery.min.css" | $scratch.Add "linkLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
{{- with $CDN.lightgalleryJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/lightgallery/lightgallery.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
{{- with $CDN.lightgalleryThumbnailJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/lightgallery/lg-thumbnail.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
{{- with $CDN.lightgalleryZoomJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "lib/lightgallery/lg-zoom.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-24 10:00:39 +01:00
{{- end -}}
<script>
document.addEventListener('DOMContentLoaded', function () {
lightGallery(document.getElementById('content'), {
selector: '.lightgallery',
speed: 400,
hideBarsDelay: 2000,
thumbnail: true,
exThumbImage: 'data-thumbnail',
thumbWidth: 80,
thumbContHeight: 80,
});
});
</script>
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- /* TypeIt */ -}}
2020-02-24 10:00:39 +01:00
{{- with $scratch.Get "typeitMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.typeitJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/typeit/typeit.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- range $key, $val := . -}}
2020-02-24 10:00:39 +01:00
{{- slice $val | $scratch.Add "typeitArr" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
<script>
2020-02-24 10:00:39 +01:00
window.typeitArr = {{ $scratch.Get "typeitArr" | jsonify | safeJS }};
2020-02-14 14:09:21 +01:00
</script>
{{- end -}}
{{- /* KaTeX */ -}}
2020-02-24 10:00:39 +01:00
{{- if ne .Site.Params.math.enable false | and .Params.math -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexCSS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "linkCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/katex.min.css" | $scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/katex.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexAutoRenderJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/auto-render.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- $math := .Site.Params.math -}}
2020-02-16 19:32:52 +01:00
{{- if $math.copyTex -}}
{{- with $CDN.katexCopyTexCSS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "linkCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/copy-tex.min.css" | $scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexCopyTexJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/copy-tex.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- end -}}
{{- if $math.mhchem -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexMhchemJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/katex/mhchem.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- end -}}
<script>
2020-02-24 10:00:39 +01:00
document.addEventListener('DOMContentLoaded', function () {
2020-02-14 14:09:21 +01:00
renderMathInElement(document.body, {
delimiters: [
2020-02-24 10:00:39 +01:00
{ left: '$$', right: '$$', display: true },
{ left: '\\[', right: '\\]', display: true },
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
2020-02-24 10:00:39 +01:00
{ left: '{{ $math.blockLeftDelimiter }}', right: '{{ $math.blockRightDelimiter }}', display: true },
{{- end -}}
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
{ left: '{{ $math.inlineLeftDelimiter }}', right: '{{ $math.inlineRightDelimiter }}', display: false },
{{- end -}}
2020-02-14 14:09:21 +01:00
]
});
});
</script>
{{- end -}}
{{- /* mermaid */ -}}
2020-02-24 10:00:39 +01:00
{{- with $scratch.Get "mermaidMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.mermaidJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/mermaid/mermaid.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-24 10:00:39 +01:00
{{- slice "css/mermaid.scss" | $scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
<script>
window.mermaidMap = {{ jsonify . | safeJS }};
</script>
{{- end -}}
{{- /* Music */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "music" -}}
{{- /* APlayer */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.aplayerCSS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "linkCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/aplayer/APlayer.min.css" | $scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- slice "lib/aplayer/dark.scss" | $scratch.Add "linkLocal" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.aplayerJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/aplayer/APlayer.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- /* MetingJS */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.metingJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/meting/Meting.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- end -}}
{{- /* dev feature */ -}}
{{- if .Params.dev -}}
{{- /* ECharts */ -}}
2020-02-24 10:00:39 +01:00
{{- with $scratch.Get "echartsMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.echartsJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/echarts/echarts.min.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.echartsMacaronsJS -}}
2020-02-24 10:00:39 +01:00
{{- slice . | $scratch.Add "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- else -}}
{{- slice "lib/echarts/macarons.js" | $scratch.Add "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
<script>
window.echartsMap = {
{{- range $key, $var := . -}}
{{- $key }}: {{ $var | safeJS -}},
{{- end -}}
};
</script>
{{- end -}}
{{- end -}}
2020-02-24 10:00:39 +01:00
{{- range $scratch.Get "linkCDN" -}}
2020-02-14 14:09:21 +01:00
{{- safeHTML . -}}
{{- end -}}
2020-02-24 10:00:39 +01:00
{{- range $scratch.Get "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- $res := resources.Get . -}}
2020-02-14 15:07:46 +01:00
{{- if strings.HasSuffix . ".scss" -}}
{{- $options := dict "outputStyle" "compressed" "enableSourceMap" true -}}
{{- $res = toCSS $options $res -}}
{{- else if not (strings.HasSuffix . ".min.css") -}}
2020-02-14 14:09:21 +01:00
{{- $res = minify $res -}}
{{- end -}}
<link rel="stylesheet" href="{{ $res.RelPermalink }}">
{{- end -}}
2020-02-24 10:00:39 +01:00
{{- range $scratch.Get "scriptCDN" -}}
2020-02-14 14:09:21 +01:00
{{- safeHTML . -}}
{{- end -}}
2020-02-24 10:00:39 +01:00
{{- range $scratch.Get "scriptLocal" -}}
2020-02-14 14:09:21 +01:00
{{- $res := resources.Get . -}}
{{- if not (strings.HasSuffix . ".min.js") -}}
{{- $res = minify $res -}}
{{- end -}}
<script src="{{ $res.RelPermalink }}"></script>
{{- end -}}
2020-02-16 17:41:08 +01:00
{{- /* Theme script */ -}}
<script src=/js/theme.min.js></script>
{{- /* Google analytics async */ -}}
2020-02-24 10:00:39 +01:00
{{- if $scratch.Get "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}