2020-02-03 13:47:49 +01:00
|
|
|
{{- /* Google analytics async */ -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.GoogleAnalytics -}}
|
|
|
|
{{- template "_internal/google_analytics_async.html" . -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- /* jQuery https://github.com/jquery/jquery */ -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $jquery := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.jquery_js -}}
|
|
|
|
{{- $jquery = .Site.Params.cdn.jquery_js -}}
|
|
|
|
{{- else -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- $res := resources.Get "js/lib/jquery/jquery.slim.min.js" -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $jquery = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $jquery | safeHTML -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
|
|
|
|
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $lazysizes := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.lazysizes_js -}}
|
|
|
|
{{- $lazysizes = .Site.Params.cdn.lazysizes_js -}}
|
|
|
|
{{- else -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- $res := resources.Get "js/lib/lazysizes/lazysizes.min.js" -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $lazysizes = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $lazysizes | safeHTML -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
|
|
|
|
{{- /* Smooth Scroll https://github.com/cferdinandi/smooth-scroll */ -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $smooth_scroll := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.smooth_scroll_js -}}
|
|
|
|
{{- $smooth_scroll = .Site.Params.cdn.smooth_scroll_js -}}
|
|
|
|
{{- else -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- $res := resources.Get "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- $smooth_scroll = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $smooth_scroll = delimit (slice $smooth_scroll "<script>window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true});</script>") "" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $smooth_scroll | safeHTML -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
|
|
|
|
{{- /* TypeIt https://github.com/alexmacarthur/typeit */ -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- if .Scratch.Get "typeitMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $typeit := "" -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.typeit_js -}}
|
|
|
|
{{- $typeit = .Site.Params.cdn.typeit_js -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/typeit/typeit.min.js" -}}
|
|
|
|
{{- $typeit = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $typeit | safeHTML -}}
|
|
|
|
{{- $typeitArr := slice -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- range $key, $val := .Scratch.Get "typeitMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $typeitArr = $typeitArr | append (slice $val) -}}
|
|
|
|
{{- end -}}
|
|
|
|
<script>
|
|
|
|
{{- printf "window.typeitArr=%s;" (jsonify $typeitArr) | safeJS -}}
|
|
|
|
</script>
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* KaTeX https://github.com/KaTeX/KaTeX */ -}}
|
2020-02-03 14:36:46 +01:00
|
|
|
{{- if .Site.Params.math.enable | and (ne .Params.math false) -}}
|
|
|
|
{{- $math := .Site.Params.math -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $katex_css := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_css -}}
|
|
|
|
{{- $katex_css = .Site.Params.cdn.katex_css -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "css/lib/katex/katex.min.css" -}}
|
|
|
|
{{- $katex_css = printf "<link rel=\"stylesheet\" href=\"%s\">" $res.RelPermalink -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $katex_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_js -}}
|
|
|
|
{{- $katex_js = .Site.Params.cdn.katex_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/katex/katex.min.js" -}}
|
|
|
|
{{- $katex_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $katex_auto_render_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_auto_render_js -}}
|
|
|
|
{{- $katex_auto_render_js = .Site.Params.cdn.katex_auto_render_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/katex/auto-render.min.js" -}}
|
2020-02-03 14:36:46 +01:00
|
|
|
{{- $katex_auto_render_js = printf "<script defer src=\"%s\"></script>" $res.RelPermalink -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $katex := delimit (slice $katex_css $katex_js $katex_auto_render_js) "" -}}
|
2020-02-03 14:36:46 +01:00
|
|
|
{{- if $math.copy_tex -}}
|
|
|
|
{{- $katex_copy_tex_css := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_copy_tex_css -}}
|
|
|
|
{{- $katex_copy_tex_css = .Site.Params.cdn.katex_copy_tex_css -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "css/lib/katex/copy-tex.min.css" -}}
|
|
|
|
{{- $katex_copy_tex_css = printf "<link rel=\"stylesheet\" href=\"%s\">" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $katex_copy_tex_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_copy_tex_js -}}
|
|
|
|
{{- $katex_copy_tex_js = .Site.Params.cdn.katex_copy_tex_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/katex/copy-tex.min.js" -}}
|
|
|
|
{{- $katex_copy_tex_js = printf "<script defer src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $katex = delimit (slice $katex $katex_copy_tex_css $katex_copy_tex_js) "" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if $math.mhchem -}}
|
|
|
|
{{- $katex_mhchem_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_mhchem_js -}}
|
|
|
|
{{- $katex_mhchem_js = .Site.Params.cdn.katex_mhchem_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/katex/mhchem.min.js" -}}
|
|
|
|
{{- $katex_mhchem_js = printf "<script defer src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $katex = delimit (slice $katex $katex_mhchem_js) "" -}}
|
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $katex | safeHTML -}}
|
2020-02-03 14:36:46 +01:00
|
|
|
<script>
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
renderMathInElement(document.body, {
|
|
|
|
delimiters: [
|
|
|
|
{ left: "$$", right: "$$", display: true },
|
|
|
|
{ left: "\\(", right: "\\)", display: false },
|
|
|
|
{ left: "\\[", right: "\\]", display: true },
|
|
|
|
{{- if and $math.block_left_delimiter $math.block_right_delimiter -}}
|
|
|
|
{ left: "{{ $math.block_left_delimiter }}", right: "{{ $math.block_right_delimiter }}", display: true },
|
|
|
|
{{- end -}}
|
|
|
|
{{- if and $math.inline_left_delimiter $math.inline_right_delimiter -}}
|
|
|
|
{ left: "{{ $math.inline_left_delimiter }}", right: "{{ $math.inline_right_delimiter }}", display: false },
|
|
|
|
{{- end -}}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- end -}}
|
2019-08-17 17:16:09 +02:00
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* mermaid https://github.com/knsv/mermaid */ -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- if .Scratch.Get "mermaidMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $mermaid := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.mermaid_js -}}
|
|
|
|
{{- $mermaid = .Site.Params.cdn.mermaid_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/mermaid/mermaid.min.js" -}}
|
|
|
|
{{- $mermaid = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $mermaidInit := "<script>mermaid.initialize({startOnLoad: false, theme: null});</script>" -}}
|
|
|
|
{{- $mermaid = delimit (slice $mermaid $mermaidInit) "" -}}
|
|
|
|
{{- $mermaid | safeHTML -}}
|
|
|
|
<script>
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- printf "window.mermaidMap=%s;" (jsonify .Scratch.Get "mermaidMap") | safeJS -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
</script>
|
|
|
|
{{- end -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* Music */ -}}
|
|
|
|
{{- if .Scratch.Get "music" -}}
|
|
|
|
{{- /* APlayer https://github.com/MoePlayer/APlayer */ -}}
|
|
|
|
{{- $aplayer_css := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.aplayer_css -}}
|
|
|
|
{{- $aplayer_css = .Site.Params.cdn.aplayer_css -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "css/lib/aplayer/APlayer.min.css" -}}
|
|
|
|
{{- $aplayer_css = printf "<link rel=\"stylesheet\" href=\"%s\">" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $aplayer_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.aplayer_js -}}
|
|
|
|
{{- $aplayer_js = .Site.Params.cdn.aplayer_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/aplayer/APlayer.min.js" -}}
|
|
|
|
{{- $aplayer_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $aplayer := delimit (slice $aplayer_css $aplayer_js) "" -}}
|
|
|
|
{{- $aplayer | safeHTML -}}
|
|
|
|
|
|
|
|
{{- /* MetingJS https://github.com/metowolf/MetingJS */ -}}
|
|
|
|
{{- $meting := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.meting_js -}}
|
|
|
|
{{- $meting = .Site.Params.cdn.meting_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/meting/Meting.min.js" -}}
|
|
|
|
{{- $meting = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
2020-02-03 11:38:10 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $meting | safeHTML -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2019-03-13 23:38:18 +01:00
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* jQuery.countdown https://github.com/hilios/jQuery.countdown */ -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- if .Scratch.Get "countdownMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $countdown := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.jquery_countdown_js -}}
|
|
|
|
{{- $countdown = .Site.Params.cdn.jquery_countdown_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/jquery-countdown/jquery.countdown.min.js" -}}
|
|
|
|
{{- $countdown = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
{{- end -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $countdown | safeHTML -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
<script>
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- printf "window.countdownMap=%s;" (jsonify .Scratch.Get "countdownMap") | safeJS -}}
|
2020-01-31 15:53:04 +01:00
|
|
|
</script>
|
|
|
|
{{- end -}}
|
2019-08-16 21:40:34 +02:00
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* dev feature */ -}}
|
|
|
|
{{- if .Params.dev -}}
|
|
|
|
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}}
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- if .Scratch.Get "echartsMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $echarts_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_js -}}
|
|
|
|
{{- $echarts_js = .Site.Params.cdn.echarts_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/echarts/echarts.min.js" -}}
|
|
|
|
{{- $echarts_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $echarts_macarons_js := "" -}}
|
|
|
|
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_macarons_js -}}
|
|
|
|
{{- $echarts_macarons_js = .Site.Params.cdn.echarts_macarons_js -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $res := resources.Get "js/lib/echarts/macarons.js" | minify -}}
|
|
|
|
{{- $echarts_macarons_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $echarts := delimit (slice $echarts_js $echarts_macarons_js) "" -}}
|
|
|
|
{{- $echarts | safeHTML -}}
|
|
|
|
<script>
|
|
|
|
window.echartsMap = {
|
2020-02-07 14:42:47 +01:00
|
|
|
{{- range $key, $var := .Scratch.Get "echartsMap" -}}
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- $key }}: {{ $var | safeJS -}},
|
|
|
|
{{- end -}}
|
|
|
|
};
|
|
|
|
window.echartsArr = [];
|
|
|
|
</script>
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2019-08-11 19:36:19 +02:00
|
|
|
|
2020-02-03 13:47:49 +01:00
|
|
|
{{- /* Blog script */ -}}
|
|
|
|
{{- $res := resources.Get "/js/blog.js" | minify -}}
|
2020-02-06 17:10:00 +01:00
|
|
|
<script src="{{ $res.RelPermalink }}"></script>
|