LoveIt/layouts/partials/script.html

186 lines
6.8 KiB
HTML
Raw Normal View History

2020-02-14 14:09:21 +01:00
{{- $CDN := .Scratch.Get "CDN" -}}
{{- /* Fork Awesome https://forkaweso.me/ */ -}}
{{- if .Scratch.Get "forkawesome" -}}
{{- slice "css/lib/forkawesome/fork-awesome.scss" | .Scratch.Add "linkLocal" -}}
2020-02-14 14:09:21 +01:00
{{- end -}}
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.lazysizesJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lazysizes/lazysizes.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* Smooth Scroll https://github.com/cferdinandi/smooth-scroll */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.smoothScrollJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* TypeIt https://github.com/alexmacarthur/typeit */ -}}
{{- with .Scratch.Get "typeitMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.typeitJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/typeit/typeit.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- range $key, $val := . -}}
{{- slice $val | $.Scratch.Add "typeitArr" -}}
{{- end -}}
<script>
window.typeitArr = {{ $.Scratch.Get "typeitArr" | jsonify | safeJS }};
</script>
{{- end -}}
{{- /* KaTeX https://github.com/KaTeX/KaTeX */ -}}
{{- if .Site.Params.math.enable | and (ne .Params.math false) -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexCSS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/katex/katex.min.css" | .Scratch.Add "linkLocal" -}}
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/katex.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexAutoRenderJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/auto-render.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- $math := .Site.Params.math -}}
2020-02-16 19:32:52 +01:00
{{- if $math.copyTex -}}
{{- with $CDN.katexCopyTexCSS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/katex/copy-tex.min.css" | .Scratch.Add "linkLocal" -}}
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexCopyTexJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/copy-tex.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- if $math.mhchem -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.katexMhchemJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/mhchem.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "\\(", right: "\\)", display: false },
{ left: "\\[", right: "\\]", display: true },
2020-02-16 19:32:52 +01:00
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
{ left: "{{ $math.blockLeftDelimiter }}", right: "{{ $math.blockRightDelimiter }}", display: true },
2020-02-14 14:09:21 +01:00
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
{ left: "{{ $math.inlineLeftDelimiter }}", right: "{{ $math.inlineRightDelimiter }}", display: false },
2020-02-14 14:09:21 +01:00
{{- end -}}
]
});
});
</script>
{{- end -}}
{{- /* mermaid https://github.com/knsv/mermaid */ -}}
{{- with .Scratch.Get "mermaidMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.mermaidJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/mermaid/mermaid.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
2020-02-14 15:07:46 +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 */ -}}
{{- if .Scratch.Get "music" -}}
{{- /* APlayer https://github.com/MoePlayer/APlayer */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.aplayerCSS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/aplayer/APlayer.min.css" | .Scratch.Add "linkLocal" -}}
{{- end -}}
2020-02-14 15:07:46 +01:00
{{- slice "css/lib/aplayer/dark.scss" | .Scratch.Add "linkLocal" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.aplayerJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/aplayer/APlayer.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* MetingJS https://github.com/metowolf/MetingJS */ -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.metingJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/meting/Meting.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- /* dev feature */ -}}
{{- if .Params.dev -}}
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}}
{{- with .Scratch.Get "echartsMap" -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.echartsJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/echarts/echarts.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
2020-02-16 19:32:52 +01:00
{{- with $CDN.echartsMacaronsJS -}}
2020-02-14 14:09:21 +01:00
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/echarts/macarons.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
window.echartsMap = {
{{- range $key, $var := . -}}
{{- $key }}: {{ $var | safeJS -}},
{{- end -}}
};
window.echartsArr = [];
</script>
{{- end -}}
{{- end -}}
{{- range .Scratch.Get "linkCDN" -}}
{{- safeHTML . -}}
{{- end -}}
{{- range .Scratch.Get "linkLocal" -}}
{{- $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 -}}
{{- range .Scratch.Get "scriptCDN" -}}
{{- safeHTML . -}}
{{- end -}}
{{- range .Scratch.Get "scriptLocal" -}}
{{- $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 */ -}}
{{- if .Scratch.Get "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}