feat(search): add local search (#231)
* feat(search): add local search * docs: add docs for search
This commit is contained in:
@@ -10,13 +10,10 @@
|
||||
<a href="{{ `/` | relLangURL }}" title="{{ T `backToHome` }}">↩︎</a>
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
var emojiArray = [
|
||||
'\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)',
|
||||
'(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/',
|
||||
];
|
||||
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
|
||||
var errorEmojiContainer = document.getElementById('error-emoji');
|
||||
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var emojiArray = ['\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)','(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/'];
|
||||
document.getElementById('error-emoji').appendChild(document.createTextNode(emojiArray[Math.floor(Math.random() * emojiArray.length)]));
|
||||
})();
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
@@ -33,19 +33,10 @@
|
||||
</head>
|
||||
<body>
|
||||
{{- /* Check theme isDark before body rendering */ -}}
|
||||
<script>
|
||||
if (!window.localStorage || !window.localStorage.getItem('theme')) {
|
||||
{{- $theme := .Site.Params.defaultTheme -}}
|
||||
{{- if eq $theme "auto" -}}
|
||||
window.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
{{- else -}}
|
||||
window.isDark = '{{ $theme }}' === 'dark';
|
||||
{{- end -}}
|
||||
} else {
|
||||
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
|
||||
}
|
||||
window.isDark && document.body.classList.add('dark-theme');
|
||||
</script>
|
||||
{{- $theme := .Site.Params.defaultTheme -}}
|
||||
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ .Site.Params.defaultTheme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ .Site.Params.defaultTheme }}' === 'dark')) && document.body.classList.add('dark');</script>
|
||||
|
||||
<div id="mask"></div>
|
||||
|
||||
{{- /* Body wrapper */ -}}
|
||||
<div class="wrapper">
|
||||
@@ -60,12 +51,12 @@
|
||||
|
||||
<div id="fixed-buttons" class="animated faster">
|
||||
{{- /* top button */ -}}
|
||||
<a href="#" id="top-button" class="fixed-button" title="{{ T `backToTop` }}">
|
||||
<a href="#" id="back-to-top" class="fixed-button" title="{{ T `backToTop` }}">
|
||||
<i class="fas fa-arrow-up fa-fw"></i>
|
||||
</a>
|
||||
|
||||
{{- /* comment button */ -}}
|
||||
<a href="#" id="comment-button" class="fixed-button" title="{{ T `viewComments` }}">
|
||||
<a href="#" id="view-comments" class="fixed-button" title="{{ T `viewComments` }}">
|
||||
<i class="fas fa-comment fa-fw"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- partial "single/content.html" .Content -}}
|
||||
{{- partial "function/content.html" .Content | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
{{- /* Summary content */ -}}
|
||||
<div class="content">
|
||||
{{- with .Summary -}}
|
||||
{{- partial "single/content.html" . -}}
|
||||
{{- partial "function/content.html" . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- .Description | safeHTML -}}
|
||||
{{- end -}}
|
||||
|
||||
15
layouts/index.json
Normal file
15
layouts/index.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{{- $index := slice -}}
|
||||
{{- range where .Site.RegularPages ".Params.hiddenfromsearch" "!=" true -}}
|
||||
{{- $one := dict "uri" .RelPermalink "title" .Title "description" (.Description | default "") -}}
|
||||
{{- $tags := .Params.tags | default slice -}}
|
||||
{{- $one = delimit $tags "\n" | dict "tags" | merge $one -}}
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
|
||||
{{- $one = dict "date" $publish_date | merge $one -}}
|
||||
{{- $content := partial "function/content.html" .Content | plainify -}}
|
||||
{{- if gt .Site.Params.search.contentLength 0 -}}
|
||||
{{- $content = substr $content 0 .Site.Params.search.contentLength -}}
|
||||
{{- end -}}
|
||||
{{- $one = dict "content" $content | merge $one -}}
|
||||
{{- $index = $index | append $one -}}
|
||||
{{- end -}}
|
||||
{{- $index | jsonify | safeJS -}}
|
||||
@@ -1,219 +1,241 @@
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
{{- $config := dict "desktopHeaderMode" .Site.Params.header.desktopMode "mobileHeaderMode" .Site.Params.header.mobileMode -}}
|
||||
{{- with $scratch.Get "contentData" -}}
|
||||
{{- $config = dict "content" . | merge $config -}}
|
||||
{{- end -}}
|
||||
{{- with $scratch.Get "comment" -}}
|
||||
{{- $config = dict "comment" . | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Fork Awesome */ -}}
|
||||
{{- if $scratch.Get "forkawesome" -}}
|
||||
{{- slice "lib/forkawesome/fork-awesome.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/forkawesome/fork-awesome.min.css" -}}
|
||||
{{- dict "source" "lib/forkawesome/fork-awesome.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* iconfont */ -}}
|
||||
{{- if $scratch.Get "iconfont" -}}
|
||||
{{- with $CDN.iconfontCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/iconfont/iconfont.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/iconfont/iconfont.css" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Smooth Scroll */ -}}
|
||||
{{- with $CDN.smoothScrollJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/smooth-scroll/smooth-scroll.polyfills.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/smooth-scroll/smooth-scroll.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Sharer.js */ -}}
|
||||
{{- if $scratch.Get "share" -}}
|
||||
{{- with $CDN.sharerJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- /* Search */ -}}
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
{{- with $CDN.autocompleteJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/sharer/sharer.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/autocomplete/autocomplete.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- 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" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/lunr/lunr.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- 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 | slice | $scratch.Add "script" -}}
|
||||
{{- dict "source" (T "lunrLanguageLib") "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- else if eq .Site.Params.search.type "algolia" -}}
|
||||
{{- with $CDN.algoliasearchJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/algoliasearch/algoliasearch-lite.umd.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- 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 -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lazysizes/lazysizes.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* lightgallery.js */ -}}
|
||||
{{- if ne .Site.Params.page.lightgallery false | and (ne .Params.lightgallery false) -}}
|
||||
{{- with $CDN.lightgalleryCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lightgallery.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lightgallery.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lightgallery.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lightgallery.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryThumbnailJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lg-thumbnail.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lg-thumbnail.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryZoomJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lg-zoom.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lg-zoom.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- 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 -}}
|
||||
|
||||
{{- /* Sharer.js */ -}}
|
||||
{{- if $scratch.Get "share" -}}
|
||||
{{- with $CDN.sharerJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/sharer/sharer.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- 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,
|
||||
actualSize: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* TypeIt */ -}}
|
||||
{{- with $scratch.Get "typeitMap" -}}
|
||||
{{- with $CDN.typeitJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/typeit/typeit.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/typeit/typeit.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $typeitConfig := slice -}}
|
||||
{{- range $key, $val := . -}}
|
||||
{{- slice $val | $scratch.Add "typeitArr" -}}
|
||||
{{- $typeitConfig = $typeitConfig | append (slice $val) -}}
|
||||
{{- end -}}
|
||||
<script>
|
||||
window.typeitArr = {{ $scratch.Get "typeitArr" | jsonify | safeJS }};
|
||||
</script>
|
||||
{{- $config = dict "typeit" $typeitConfig | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* KaTeX */ -}}
|
||||
{{- if ne .Site.Params.math.enable false | and .Params.math -}}
|
||||
{{- with $CDN.katexCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/katex.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/katex/katex.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/katex.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/katex.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexAutoRenderJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/auto-render.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/auto-render.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $math := .Site.Params.math -}}
|
||||
{{- if $math.copyTex -}}
|
||||
{{- with $CDN.katexCopyTexCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/copy-tex.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/katex/copy-tex.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexCopyTexJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/copy-tex.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/copy-tex.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $math.mhchem -}}
|
||||
{{- with $CDN.katexMhchemJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/mhchem.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/mhchem.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{ left: '$$', right: '$$', display: true },
|
||||
{ left: '\\[', right: '\\]', display: true },
|
||||
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
|
||||
{ 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 -}}
|
||||
],
|
||||
strict: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- $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 "mermaid" -}}
|
||||
{{- with $CDN.mermaidJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mermaid/mermaid.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/mermaid/mermaid.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/mermaid/mermaid.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" -}}
|
||||
{{- dict "source" "lib/mermaid/mermaid.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* ECharts */ -}}
|
||||
{{- if $scratch.Get "echarts" -}}
|
||||
{{- with $CDN.echartsJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/echarts/echarts.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/echarts/echarts.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.echartsMacaronsJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/echarts/macarons.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/echarts/macarons.js" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Mapbox GL */ -}}
|
||||
{{- if $scratch.Get "mapbox" -}}
|
||||
{{- with $CDN.mapboxGLCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.mapboxGLJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl-language.js" | $scratch.Add "scriptLocal" -}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
mapboxgl.accessToken = '{{ .Params.mapbox.accessToken | default .Site.Params.mapbox.accessToken }}';
|
||||
mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js');
|
||||
});
|
||||
</script>
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl-language.js" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- $mapbox := dict "accessToken" (.Params.mapbox.accessToken | default .Site.Params.mapbox.accessToken) "RTLTextPlugin" "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js" -}}
|
||||
{{- $config = dict "mapbox" $mapbox | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Music */ -}}
|
||||
{{- if $scratch.Get "music" -}}
|
||||
{{- /* APlayer */ -}}
|
||||
{{- with $CDN.aplayerCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/aplayer/APlayer.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/aplayer/APlayer.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/aplayer/dark.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/aplayer/dark.min.css" -}}
|
||||
{{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- with $CDN.aplayerJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/aplayer/APlayer.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/aplayer/APlayer.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* MetingJS */ -}}
|
||||
{{- with $CDN.metingJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/meting/Meting.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/meting/Meting.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -221,41 +243,20 @@
|
||||
{{- if .Params.dev -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $scratch.Get "contentMap" -}}
|
||||
<script>
|
||||
window.contentMap = {{ jsonify . | safeJS }};
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Theme script */ -}}
|
||||
{{- slice "js/theme.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
|
||||
|
||||
{{- range $scratch.Get "linkCDN" -}}
|
||||
{{- safeHTML . -}}
|
||||
{{- end -}}
|
||||
{{- range $scratch.Get "linkLocal" -}}
|
||||
{{- $res := resources.Get . -}}
|
||||
{{- if strings.HasSuffix . ".scss" -}}
|
||||
{{- $options := dict "outputStyle" "compressed" "enableSourceMap" true -}}
|
||||
{{- $res = toCSS $options $res -}}
|
||||
{{- else if not (strings.HasSuffix . ".min.css") -}}
|
||||
{{- $res = minify $res -}}
|
||||
{{- end -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- range $scratch.Get "stylesheet" -}}
|
||||
{{- partial "plugin/stylesheet.html" . -}}
|
||||
{{- 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 := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/script.html" $script -}}
|
||||
<script type="text/javascript">
|
||||
window.config = {{ jsonify $config | safeJS }};
|
||||
</script>
|
||||
|
||||
{{- range $scratch.Get "script" -}}
|
||||
{{- partial "plugin/script.html" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Google analytics async */ -}}
|
||||
|
||||
@@ -1,126 +1,112 @@
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
|
||||
{{- if eq hugo.Environment "production" | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
|
||||
{{- /* Disqus Comment System */ -}}
|
||||
{{- if .Site.Params.comment.disqus.enable -}}
|
||||
<div id="disqus_thread" class="comment"></div>
|
||||
{{- $script := printf `<script defer src="https://%s.disqus.com/embed.js"></script>` .Site.Params.comment.disqus.shortname -}}
|
||||
{{- slice $script | $scratch.Add "scriptCDN" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Gitalk Comment System */ -}}
|
||||
{{- if .Site.Params.comment.gitalk.enable -}}
|
||||
{{- $gitalk := .Site.Params.comment.gitalk -}}
|
||||
<div id="gitalk" class="comment"></div>
|
||||
{{- with $CDN.gitalkCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/gitalk/gitalk.css" | $scratch.Add "linkLocal" -}}
|
||||
<div id="comments">
|
||||
{{- /* Disqus Comment System */ -}}
|
||||
{{- if .Site.Params.comment.disqus.enable -}}
|
||||
<div id="disqus_thread" class="comment"></div>
|
||||
{{- $source := printf "https://%s.disqus.com/embed.js" .Site.Params.comment.disqus.shortname -}}
|
||||
{{- dict "source" $source "defer" true "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://disqus.com/?ref_noscript">Disqus</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- with $CDN.gitalkJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/gitalk/gitalk.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
|
||||
{{- /* Gitalk Comment System */ -}}
|
||||
{{- if .Site.Params.comment.gitalk.enable -}}
|
||||
{{- $gitalk := .Site.Params.comment.gitalk -}}
|
||||
<div id="gitalk" class="comment"></div>
|
||||
{{- with $CDN.gitalkCSS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/gitalk/gitalk.css" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.gitalkJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/gitalk/gitalk.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $gitalkConfig := dict "id" .Date "title" .Title "clientID" $gitalk.clientId "clientSecret" $gitalk.clientSecret "repo" $gitalk.repo "owner" $gitalk.owner "admin" (slice $gitalk.owner) -}}
|
||||
{{- $scratch.SetInMap "comment" "gitalk" $gitalkConfig -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://github.com/gitalk/gitalk"></a>Gitalk</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var gitalk = new Gitalk({
|
||||
id: '{{ .Date }}',
|
||||
title: '{{ .Title }}',
|
||||
clientID: '{{ $gitalk.clientId }}',
|
||||
clientSecret: '{{ $gitalk.clientSecret }}',
|
||||
repo: '{{ $gitalk.repo }}',
|
||||
owner: '{{ $gitalk.owner }}',
|
||||
admin: ['{{ $gitalk.owner }}'],
|
||||
body: decodeURI(location.href),
|
||||
});
|
||||
gitalk.render('gitalk');
|
||||
});
|
||||
</script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by Gitalk.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Valine Comment System */ -}}
|
||||
{{- if .Site.Params.comment.valine.enable -}}
|
||||
{{- $valine := .Site.Params.comment.valine -}}
|
||||
<div id="valine" class="comment"></div>
|
||||
{{- slice "lib/valine/valine.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- with $CDN.valineJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/valine/Valine.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- /* Valine Comment System */ -}}
|
||||
{{- if .Site.Params.comment.valine.enable -}}
|
||||
{{- $valine := .Site.Params.comment.valine -}}
|
||||
<div id="valine" class="comment"></div>
|
||||
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}}
|
||||
{{- dict "source" "lib/valine/valine.scss" "toCSS" $options | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- with $CDN.valineJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/valine/Valine.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $valineConfig := dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default "en") "notify" $valine.notify "verify" $valine.verify "visitor" $valine.visitor "recordIP" $valine.recordIP -}}
|
||||
{{- with $valine.placeholder -}}
|
||||
{{- $valineConfig = dict "placeholder" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.avatar -}}
|
||||
{{- $valineConfig = dict "avatar" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.meta -}}
|
||||
{{- $valineConfig = dict "meta" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.pageSize -}}
|
||||
{{- $valineConfig = dict "pageSize" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- $scratch.SetInMap "comment" "valine" $valineConfig -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://valine.js.org/">Valine</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
new Valine({
|
||||
el: '#valine',
|
||||
appId: '{{ $valine.appId }}',
|
||||
appKey: '{{ $valine.appKey }}',
|
||||
{{- with $valine.placeholder -}}
|
||||
placeholder: '{{ . }}',
|
||||
{{- end -}}
|
||||
{{- if $valine.notify -}}
|
||||
notify: true,
|
||||
{{- end -}}
|
||||
{{- if $valine.verify -}}
|
||||
verify: true,
|
||||
{{- end -}}
|
||||
{{- with $valine.avatar -}}
|
||||
avatar: '{{ . }}',
|
||||
{{- end -}}
|
||||
{{- with $valine.meta -}}
|
||||
meta: {{ . | safeJS }},
|
||||
{{- end -}}
|
||||
{{- with $valine.pageSize -}}
|
||||
pageSize: {{ . | safeJS }},
|
||||
{{- end -}}
|
||||
lang: '{{ $valine.lang | default "en" }}',
|
||||
{{- if $valine.visitor -}}
|
||||
visitor: true,
|
||||
{{- end -}}
|
||||
{{- if $valine.recordIP -}}
|
||||
recordIP: true,
|
||||
{{- end -}}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://valine.js.org/">comments powered by Valine.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Facebook Comment System */ -}}
|
||||
{{- if .Site.Params.comment.facebook.enable -}}
|
||||
{{- $facebook := .Site.Params.comment.facebook -}}
|
||||
<div id="fb-root" class="comment"></div>
|
||||
<div
|
||||
class="fb-comments"
|
||||
data-href="{{ .Site.Params.baseURL }}{{ .Permalink | absURL }}"
|
||||
data-width="{{ $facebook.width }}"
|
||||
data-numposts="{{ $facebook.numPosts }}"
|
||||
></div>
|
||||
{{- $script := `<script src="https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" crossorigin="anonymous"></script>` -}}
|
||||
{{- $script = printf $script $facebook.languageCode $facebook.appId -}}
|
||||
{{- slice $script | $scratch.Add "scriptCDN" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://developers.facebook.com/docs/plugins/comments/">comments powered by Facebook.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- /* Facebook Comment System */ -}}
|
||||
{{- if .Site.Params.comment.facebook.enable -}}
|
||||
{{- $facebook := .Site.Params.comment.facebook -}}
|
||||
<div id="fb-root" class="comment"></div>
|
||||
<div
|
||||
class="fb-comments"
|
||||
data-href="{{ .Site.Params.baseURL }}{{ .Permalink | absURL }}"
|
||||
data-width="{{ $facebook.width }}"
|
||||
data-numposts="{{ $facebook.numPosts }}"
|
||||
></div>
|
||||
{{- $source := printf "https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" $facebook.languageCode $facebook.appId -}}
|
||||
{{- dict "source" $source "defer" true "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://developers.facebook.com/docs/plugins/comments/"></a>Facebook</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Telegram Comments System */ -}}
|
||||
{{- if .Site.Params.comment.telegram.enable -}}
|
||||
{{- $telegram := .Site.Params.comment.telegram -}}
|
||||
<div id="telegram-comments" class="comment"></div>
|
||||
<script async src="https://comments.app/js/widget.js?2" data-comments-app-website="{{ $telegram.siteID }}" data-limit="{{ $telegram.limit | default 5 }}"{{ with $telegram.height }} data-height="{{ . }}"{{ end }}{{ with $telegram.color }} data-color="{{ . }}"{{ end }}{{ if $telegram.colorful }} data-colorful="1"{{ end }}{{ if $telegram.dislikes }} data-dislikes="1"{{ end }}{{ if $telegram.outlined }} data-outlined="1"{{ end }}></script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://comments.app/">comments powered by Telegram Comments.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- /* Telegram Comments System */ -}}
|
||||
{{- if .Site.Params.comment.telegram.enable -}}
|
||||
{{- $telegram := .Site.Params.comment.telegram -}}
|
||||
<div id="telegram-comments" class="comment"></div>
|
||||
{{- $attr := printf `data-comments-app-website="%s"` $telegram.siteID -}}
|
||||
{{- $attr = printf `%s data-limit="%s"` $attr ($telegram.limit | default 5) -}}
|
||||
{{- with $telegram.height -}}
|
||||
{{- $attr = printf `%s data-height="%s"` $attr . -}}
|
||||
{{- end -}}
|
||||
{{- with $telegram.color -}}
|
||||
{{- $attr = printf `%s data-color="%s"` $attr . -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.colorful -}}
|
||||
{{- $attr = printf `%s data-colorful="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.dislikes -}}
|
||||
{{- $attr = printf `%s data-dislikes="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.outlined -}}
|
||||
{{- $attr = printf `%s data-outlined="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- dict "source" "https://comments.app/js/widget.js?2" "defer" true "crossorigin" true "attr" $attr | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://comments.app/">Telegram Comments</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
|
||||
{{- $content = partial "function/escape.html" $content -}}
|
||||
|
||||
{{- $content | safeHTML -}}
|
||||
{{- return $content -}}
|
||||
@@ -3,6 +3,6 @@
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 now.Unix) "" | shuffle | first 6) "" | printf "id-%s" -}}
|
||||
{{- with .scratch -}}
|
||||
{{- .SetInMap "contentMap" $id $.content -}}
|
||||
{{- .SetInMap "contentData" $id $.content -}}
|
||||
{{- end -}}
|
||||
{{- return $id -}}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
|
||||
<link rel="canonical" href="{{ .Permalink }}" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
@@ -22,29 +23,17 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Font Awesome */ -}}
|
||||
{{- with $CDN.fontawesomeFreeCSS -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- $res := resources.Get "lib/fontawesome-free/all.min.css" -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- end -}}
|
||||
{{- $source := $CDN.fontawesomeFreeCSS | default "lib/fontawesome-free/all.min.css" -}}
|
||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
||||
{{- /* Animate.css */ -}}
|
||||
{{- with $CDN.animateCSS -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- $res := resources.Get "lib/animate/animate.min.css" -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- end -}}
|
||||
{{- $source := $CDN.animateCSS | default "lib/animate/animate.min.css" -}}
|
||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
||||
{{- /* style.min.css */ -}}
|
||||
{{- $res := resources.Get "css/style.template.scss" -}}
|
||||
{{- $options := dict "targetPath" "css/style.min.css" -}}
|
||||
{{- $options = dict "includePaths" (slice "config/css") | merge $options -}}
|
||||
{{- $options = dict "outputStyle" "compressed" | merge $options -}}
|
||||
{{- $options = dict "enableSourceMap" true | merge $options -}}
|
||||
{{- $res = resources.ExecuteAsTemplate "style.scss" . $res | toCSS $options -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- $stylesheet := dict "source" "css/style.template.scss" "fingerprint" $fingerprint -}}
|
||||
{{- $options := dict "targetPath" "css/style.min.css" "includePaths" (slice "config/css") -}}
|
||||
{{- $stylesheet = dict "template" "style.scss" "context" . "toCSS" $options | merge $stylesheet -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
||||
@@ -7,43 +7,59 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="menu">
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item{{ if $.IsMenuCurrent "main" . | or ($.HasMenuCurrent "main" .) | or (.URL | relLangURL | string | eq $.RelPermalink ) }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
{{- .Pre | safeHTML }}{{ .Name -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
<span class="menu-item">|</span>
|
||||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
|
||||
<i class="fas fa-adjust fa-fw"></i>
|
||||
</a>
|
||||
{{- if .Site.IsMultiLingual -}}
|
||||
<a href="javascript:void(0);" class="menu-item" title="{{ T "selectLanguage" }}">
|
||||
{{- .Language.LanguageName -}}
|
||||
<i class="fas fa-chevron-right fa-fw"></i>
|
||||
<select class="language-select" id="language-select-desktop" onchange="location = this.value;">
|
||||
{{- range .Page.AllTranslations -}}
|
||||
{{- $translation := . -}}
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
<div class="menu-inner">
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item{{ if $.IsMenuCurrent "main" . | or ($.HasMenuCurrent "main" .) | or (.URL | relLangURL | string | eq $.RelPermalink ) }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
{{- .Pre | safeHTML }}{{ .Name -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
<span class="menu-item delimiter"></span>
|
||||
{{- if .Site.IsMultiLingual -}}
|
||||
<a href="javascript:void(0);" class="menu-item language" title="{{ T "selectLanguage" }}">
|
||||
{{- .Language.LanguageName -}}
|
||||
<i class="fas fa-chevron-right fa-fw"></i>
|
||||
<select class="language-select" id="language-select-desktop" onchange="location = this.value;">
|
||||
{{- range .Page.AllTranslations -}}
|
||||
{{- $translation := . -}}
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</select>
|
||||
</select>
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
<span class="menu-item search" id="search-desktop">
|
||||
<input type="text" placeholder="{{ T `searchPlaceholder` }}" id="search-input-desktop">
|
||||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="{{ T `search` }}">
|
||||
<i class="fas fa-search fa-fw"></i>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="{{ T `clear` }}">
|
||||
<i class="fas fa-times-circle fa-fw"></i>
|
||||
</a>
|
||||
<span class="search-button search-loading" id="search-loading-desktop">
|
||||
<i class="fas fa-spinner fa-fw fa-spin"></i>
|
||||
</span>
|
||||
</span>
|
||||
{{- end -}}
|
||||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
|
||||
<i class="fas fa-adjust fa-fw"></i>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{{- /* Mobile header */ -}}
|
||||
<header class="mobile" id="header-mobile">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-container">
|
||||
<div class="header-container">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-title">
|
||||
<a href="{{ `/` | relLangURL }}">
|
||||
{{- .Site.Title -}}
|
||||
@@ -54,6 +70,25 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu" id="menu-mobile">
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
<div class="search-wrapper">
|
||||
<div class="search mobile" id="search-mobile">
|
||||
<input type="text" placeholder="{{ T `searchPlaceholder` }}" id="search-input-mobile">
|
||||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="{{ T `search` }}">
|
||||
<i class="fas fa-search fa-fw"></i>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="{{ T `clear` }}">
|
||||
<i class="fas fa-times-circle fa-fw"></i>
|
||||
</a>
|
||||
<span class="search-button search-loading" id="search-loading-mobile">
|
||||
<i class="fas fa-spinner fa-fw fa-spin"></i>
|
||||
</span>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
|
||||
{{ T `cancel` }}
|
||||
</a>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- $currentPage := . -}}
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item" href="{{ .URL | relLangURL }}" title="{{ .Title }}" rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
@@ -86,8 +121,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<script>
|
||||
window.desktopHeaderMode = {{ .Site.Params.header.desktopMode }};
|
||||
window.mobileHeaderMode = {{ .Site.Params.header.mobileMode }};
|
||||
</script>
|
||||
<div class="search-dropdown desktop">
|
||||
<div id="search-dropdown-desktop"></div>
|
||||
</div>
|
||||
<div class="search-dropdown mobile">
|
||||
<div id="search-dropdown-mobile"></div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<script src="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}"></script>
|
||||
{{- if strings.HasPrefix .source "<script" -}}
|
||||
{{- safeHTML .source -}}
|
||||
{{- else -}}
|
||||
<script src="{{ $res.RelPermalink }}"></script>
|
||||
{{- $src := .source -}}
|
||||
{{- $integrity := .integrity -}}
|
||||
{{- if strings.HasPrefix $src "http" | not -}}
|
||||
{{- $res := resources.Get $src -}}
|
||||
{{- with .template -}}
|
||||
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
|
||||
{{- end -}}
|
||||
{{- if .minify -}}
|
||||
{{- $res = $res | minify -}}
|
||||
{{- end -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | fingerprint . -}}
|
||||
{{- $integrity = $res.Data.Integrity -}}
|
||||
{{- end -}}
|
||||
{{- $src = $res.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<script type="text/javascript" src="{{ $src }}"{{ if .crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .async }} async{{ end }}{{ if .defer }} defer{{ end }}{{ with .attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
|
||||
{{- if strings.HasPrefix .source "<link" -}}
|
||||
{{- safeHTML .source -}}
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}">
|
||||
{{- $href := .source -}}
|
||||
{{- $integrity := .integrity -}}
|
||||
{{- if strings.HasPrefix $href "http" | not -}}
|
||||
{{- $res := resources.Get $href -}}
|
||||
{{- with .template -}}
|
||||
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
|
||||
{{- end -}}
|
||||
{{- with .toCSS -}}
|
||||
{{- $options := . | merge (dict "outputStyle" "compressed" "enableSourceMap" true) -}}
|
||||
{{- $res = $res | toCSS $options -}}
|
||||
{{- end -}}
|
||||
{{- if .minify -}}
|
||||
{{- $res = $res | minify -}}
|
||||
{{- end -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | fingerprint . -}}
|
||||
{{- $integrity = $res.Data.Integrity -}}
|
||||
{{- end -}}
|
||||
{{- $href = $res.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<link rel="stylesheet" href="{{ $href }}"{{ if .crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ with .attr }} {{ . | safeHTMLAttr }}{{ end }}>
|
||||
{{- end -}}
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
{{- define "content" -}}
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
<article class="page single">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animated flipInX">{{ .Title }}</h1>
|
||||
@@ -52,13 +62,8 @@
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* TOC */ -}}
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
</div>
|
||||
<div class="toc" id="toc-static">
|
||||
<details>
|
||||
<summary>
|
||||
@@ -79,7 +84,7 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- partial "single/content.html" .Content -}}
|
||||
{{- partial "function/content.html" .Content | safeHTML -}}
|
||||
</div>
|
||||
|
||||
{{- /* Footer */ -}}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
{{- $darkStyle = .Get 5 | default $darkStyle -}}
|
||||
{{- end -}}
|
||||
{{- $darkStyle = $darkStyle | default $lightStyle -}}
|
||||
{{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "light-style" $lightStyle "dark-style" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}}
|
||||
{{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "lightStyle" $lightStyle "darkStyle" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}}
|
||||
{{- $id := partial "function/id.html" (dict "content" $options "scratch" $scratch) -}}
|
||||
<div class="mapbox" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
|
||||
{{- $scratch.Set "mapbox" true -}}
|
||||
|
||||
Reference in New Issue
Block a user