feat(image): add image lightgallery

This commit is contained in:
Dillon
2020-02-24 17:00:39 +08:00
parent fbfcbaebca
commit 72a2e9bdcf
50 changed files with 478 additions and 353 deletions

View File

@@ -1,11 +1,13 @@
{{- if .Scratch.Get "production" | and .IsPage | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
{{- $CDN := .Scratch.Get "CDN" -}}
{{- $scratch := .Scratch.Get "scratch" -}}
{{- if $scratch.Get "production" | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
{{- $CDN := $scratch.Get "CDN" -}}
{{- /* Disqus Comment System */ -}}
{{- with .Site.Params.comment.disqus.shortname -}}
<div id="disqus_thread"></div>
{{- $script := printf `<script src="https://%s.disqus.com/embed.js"></script>` . -}}
{{- slice $script | $.Scratch.Add "scriptCDN" -}}
{{- 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>
@@ -16,14 +18,14 @@
{{- $gitalk := .Site.Params.comment.gitalk -}}
<div id="gitalk"></div>
{{- with $CDN.gitalkCSS -}}
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/gitalk/gitalk.css" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/gitalk/gitalk.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- with $CDN.gitalkJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "css/lib/gitalk/gitalk.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "css/lib/gitalk/gitalk.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
document.addEventListener("DOMContentLoaded", function(event) {
@@ -49,11 +51,11 @@
{{- if .Site.Params.comment.valine.enable -}}
{{- $valine := .Site.Params.comment.valine -}}
<div id="valine"></div>
{{- slice "css/lib/valine/dark.scss" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/valine/dark.scss" | $scratch.Add "linkLocal" -}}
{{- with $CDN.valineJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/valine/Valine.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/valine/Valine.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
document.addEventListener("DOMContentLoaded", function(event) {
@@ -106,7 +108,7 @@
></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" -}}
{{- 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>

View File

@@ -1,4 +1,5 @@
{{- $CDN := .Scratch.Get "CDN" -}}
{{- $scratch := .Scratch.Get "scratch" -}}
{{- $CDN := $scratch.Get "CDN" -}}
<link rel="canonical" href="{{ .Permalink }}" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />

View File

@@ -1,3 +1,5 @@
{{- $scratch := .Scratch.Get "scratch" -}}
<div class="home-profile">
{{- $avatar := .Site.Params.home.profile.avatarURL -}}
{{- with .Site.Params.home.profile.gravatarEmail -}}
@@ -6,7 +8,7 @@
{{- with $avatar -}}
<div class="home-avatar">
<a href="/posts">
<img src={{ . | relURL }} alt="avatar" title="{{ T "home" }}">
{{- partial "plugin/image.html" (dict "src-s" . "title" "avatar" "description" (T "home") "context" $) -}}
</a>
</div>
{{- end -}}
@@ -16,16 +18,12 @@
{{- if $.Site.Params.home.profile.typeit -}}
{{- $id := md5 . | printf "tp-%s" -}}
<div id={{ printf "r%s" $id }} hidden=true>
{{- /* FIXME: https://github.com/gohugoio/hugo/issues/6882 */ -}}
{{- /* . | $.RenderString | safeHTML */ -}}
{{- . | markdownify | safeHTML -}}
{{- . -}}
</div>
<div id={{ $id }} class="typeit"></div>
{{- $.Scratch.SetInMap "typeitMap" $id (slice $id) -}}
{{- $scratch.SetInMap "typeitMap" $id (slice $id) -}}
{{- else -}}
{{- /* FIXME: https://github.com/gohugoio/hugo/issues/6882 */ -}}
{{- /* . | $.RenderString | safeHTML */ -}}
{{- . | markdownify | safeHTML -}}
{{- . -}}
{{- end -}}
</h2>
{{- end -}}

View File

@@ -1,6 +1,6 @@
{{- if gt $.Paginator.TotalPages 1 -}}
{{- if gt .Paginator.TotalPages 1 -}}
<ul class="pagination">
{{- $.Scratch.Set "paginator.ellipsed" false -}}
{{- .Scratch.Set "paginator.ellipsed" false -}}
{{- range $.Paginator.Pagers -}}
{{- $right := sub .TotalPages .PageNumber -}}
{{- $showNumber := or (le .PageNumber 1) (eq $right 0) -}}

View File

@@ -1,6 +1,6 @@
{{- $type := index . "type" | default "fa" -}}
{{- $classList := split (index . "class") " " -}}
{{- $scratch := index . "scratch" -}}
{{- $context := index . "context" -}}
{{- /* Fork Awesome */ -}}
{{- if eq $type "fo" -}}
{{- $newClassList := slice -}}
@@ -12,11 +12,13 @@
{{- end -}}
{{- end -}}
{{- $classList = $newClassList -}}
{{- $scratch := $context.Scratch.Get "scratch" -}}
{{- $scratch.Set "forkawesome" true -}}
{{- /* default is Font Awesome */ -}}
{{- /* Others */ -}}
{{- else if ne $type "fa" -}}
{{- $scratch := $context.Scratch.Get "scratch" -}}
{{- $scratch.Set "iconfont" true -}}
{{- end -}}
<i class="{{ delimit $classList ` ` }}"></i>

View File

@@ -1,3 +1,36 @@
{{- /* Lazyload */ -}}
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink | safeURL }}" data-sizes="auto" data-src="{{ index . `src` | safeURL }}" alt="{{ index . `alt` }}" title="{{ index . `title` | default (index . `alt`) }}" class="lazyload">
{{- /* lazysizes and lightgallery.js */ -}}
{{- $src := index . "src" -}}
{{- $small := index . "src-s" | default $src -}}
{{- $large := index . "src-l" | default $src -}}
{{- $title := index . "title" -}}
{{- $description := index . "description" -}}
{{- $context := index . "context" -}}
{{- $scratch := $context.Scratch.Get "scratch" -}}
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
{{- if not (index . "src") | and (index . "src-s") -}}
{{- $loading = resources.Get "svg/loading.small.svg" | minify -}}
{{- end -}}
{{- if index . "lightgallery" -}}
<a class="lightgallery" href="{{ $large | safeURL }}" title="{{ $description }}" data-thumbnail="{{ $small | safeURL }}"{{ if $title }} data-sub-html="<h2>{{ $title }}</h2><p>{{ $description }}</p>"{{ end }}>
<img
class="lazyload"
loading="lazy"
src="{{ $loading.RelPermalink | safeURL }}"
data-sizes="auto"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ $src | safeURL }}"
alt="{{ $title | default $description }}" />
</a>
{{- $scratch.Set "lightgallery" true -}}
{{- else -}}
<img
class="lazyload"
loading="lazy"
src="{{ $loading.RelPermalink | safeURL }}"
data-sizes="auto"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ $src | safeURL }}"
alt="{{ $title | default $description }}"
title="{{ $description }}" />
{{- end -}}
{{- $scratch.Set "lazysizes" true -}}

View File

@@ -1,5 +1,7 @@
{{- if .Params.share.enable | default .Site.Params.share.enable | eq true -}}
{{- .Scratch.Set "share" true -}}
{{- $scratch := .Scratch.Get "scratch" -}}
{{- if ne .Site.Params.share.enable false | and (ne .Params.share false) -}}
{{- $scratch.Set "share" true -}}
{{- /* 001: Twitter */ -}}
{{- if .Params.Share.Twitter | default .Site.Params.Share.Twitter | eq true -}}
@@ -95,7 +97,7 @@
{{- /* 014: Instapaper */ -}}
{{- if .Params.Share.Instapaper | default .Site.Params.Share.Instapaper | eq true -}}
<a href="javascript:void(0);" title="{{ T `share` }} Instapaper" data-sharer="instapaper" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}">
{{- partial "plugin/icon.html" (dict "class" "loveit it-instapaper-fill" "type" "other" "scratch" .Scratch) -}}
{{- partial "plugin/icon.html" (dict "class" "loveit it-instapaper-fill" "type" "other" "context" .) -}}
</a>
{{- end -}}
@@ -144,7 +146,7 @@
{{- /* 021: Myspace */ -}}
{{- if .Params.Share.Myspace | default .Site.Params.Share.Myspace | eq true -}}
<a href="javascript:void(0);" title="{{ T `share` }} Myspace" data-sharer="myspace" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}">
{{- partial "plugin/icon.html" (dict "class" "loveit it-myspace-fill" "type" "other" "scratch" .Scratch) -}}
{{- partial "plugin/icon.html" (dict "class" "loveit it-myspace-fill" "type" "other" "context" .) -}}
</a>
{{- end -}}
@@ -158,7 +160,7 @@
{{- /* 023: 百度 */ -}}
{{- if .Params.Share.Baidu | default .Site.Params.Share.Baidu | eq true -}}
<a href="javascript:void(0);" title="{{ T `share` }} 百度" data-sharer="baidu" data-url="{{ .Permalink }}" data-title="{{ .Title }}">
{{- partial "plugin/icon.html" (dict "class" "loveit it-baidu-fill" "type" "other" "scratch" .Scratch) -}}
{{- partial "plugin/icon.html" (dict "class" "loveit it-baidu-fill" "type" "other" "context" .) -}}
</a>
{{- end -}}

View File

@@ -302,7 +302,7 @@
{{- /* 044: 知乎 */ -}}
{{- with .Site.Params.Social.Zhihu -}}
{{- $options := dict "href" (printf "https://www.zhihu.com/people/%s" .) "title" "知乎" "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "loveit it-zhihu-line" "type" "other" "scratch" $.Scratch) | merge $options -}}
{{- $options = dict "icon" (dict "class" "loveit it-zhihu-line" "type" "other" "context" $) | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}
@@ -394,28 +394,28 @@
{{- /* 055: Gitea */ -}}
{{- with .Site.Params.Social.Gitea -}}
{{- $options := dict "href" . "title" "Gitea" "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "fa fa-gitea fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
{{- $options = dict "icon" (dict "class" "fa fa-gitea fa-fw" "type" "fo" "context" $) | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}
{{- /* 056: XMPP */ -}}
{{- with .Site.Params.Social.XMPP -}}
{{- $options := dict "href" (printf "xmpp:%s" .) "title" "XMPP" "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "fa fa-xmpp fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
{{- $options = dict "icon" (dict "class" "fa fa-xmpp fa-fw" "type" "fo" "context" $) | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}
{{- /* 057: Matrix */ -}}
{{- with .Site.Params.Social.Matrix -}}
{{- $options := dict "href" (printf "https://matrix.to/#/%s" .) "title" "Matrix" "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "fa fa-matrix-org fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
{{- $options = dict "icon" (dict "class" "fa fa-matrix-org fa-fw" "type" "fo" "context" $) | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}
{{- /* 058: bilibili */ -}}
{{- with .Site.Params.Social.Bilibili -}}
{{- $options := dict "href" (printf "https://space.bilibili.com/%s" .) "title" "bilibili" "rel" "me" -}}
{{- $options = dict "icon" (dict "class" "loveit it-bilibili-fill" "type" "other" "scratch" $.Scratch) | merge $options -}}
{{- $options = dict "icon" (dict "class" "loveit it-bilibili-fill" "type" "other" "context" $) | merge $options -}}
{{- partial "plugin/link.html" $options -}}
{{- end -}}

View File

@@ -1,104 +1,148 @@
{{- $CDN := .Scratch.Get "CDN" -}}
{{- $localScratch := newScratch -}}
{{- $scratch := .Scratch.Get "scratch" -}}
{{- $CDN := $scratch.Get "CDN" -}}
{{- /* Fork Awesome https://forkaweso.me/ */ -}}
{{- if .Scratch.Get "forkawesome" -}}
{{- slice "css/lib/forkawesome/fork-awesome.scss" | .Scratch.Add "linkLocal" -}}
{{- if $scratch.Get "forkawesome" -}}
{{- slice "css/lib/forkawesome/fork-awesome.scss" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- /* iconfont https://www.iconfont.cn/ */ -}}
{{- if .Scratch.Get "iconfont" -}}
{{- slice "css/lib/iconfont/iconfont.css" | .Scratch.Add "linkLocal" -}}
{{- if $scratch.Get "iconfont" -}}
{{- slice "css/lib/iconfont/iconfont.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- /* Smooth Scroll https://github.com/cferdinandi/smooth-scroll */ -}}
{{- with $CDN.smoothScrollJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* Sharer.js https://github.com/ellisonleao/sharer.js */ -}}
{{- if .Scratch.Get "share" -}}
{{- if $scratch.Get "share" -}}
{{- with $CDN.sharerJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/sharer/sharer.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/sharer/sharer.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
{{- with $CDN.lazysizesJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lazysizes/lazysizes.min.js" | .Scratch.Add "scriptLocal" -}}
{{- if $scratch.Get "lazysizes" -}}
{{- with $CDN.lazysizesJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- with $CDN.lazysizesNativeLoadingJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lazysizes/ls.native-loading.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- /* lightgallery.js https://github.com/sachinchoolur/lightgallery.js */ -}}
{{- if $scratch.Get "lightgallery" -}}
{{- with $CDN.lightgalleryCSS -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/lightgallery/lightgallery.min.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- with $CDN.lightgalleryJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lightgallery/lightgallery.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- with $CDN.lightgalleryThumbnailJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lightgallery/lg-thumbnail.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- with $CDN.lightgalleryZoomJS -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/lightgallery/lg-zoom.min.js" | $scratch.Add "scriptLocal" -}}
{{- 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>
{{- end -}}
{{- /* TypeIt https://github.com/alexmacarthur/typeit */ -}}
{{- with .Scratch.Get "typeitMap" -}}
{{- with $scratch.Get "typeitMap" -}}
{{- with $CDN.typeitJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/typeit/typeit.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/typeit/typeit.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- range $key, $val := . -}}
{{- slice $val | $localScratch.Add "typeitArr" -}}
{{- slice $val | $scratch.Add "typeitArr" -}}
{{- end -}}
<script>
window.typeitArr = {{ $localScratch.Get "typeitArr" | jsonify | safeJS }};
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) -}}
{{- if ne .Site.Params.math.enable false | and .Params.math -}}
{{- with $CDN.katexCSS -}}
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/katex/katex.min.css" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/katex/katex.min.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- with $CDN.katexJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/katex.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/katex/katex.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- with $CDN.katexAutoRenderJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/auto-render.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/katex/auto-render.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- $math := .Site.Params.math -}}
{{- if $math.copyTex -}}
{{- with $CDN.katexCopyTexCSS -}}
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/katex/copy-tex.min.css" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/katex/copy-tex.min.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- with $CDN.katexCopyTexJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/copy-tex.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/katex/copy-tex.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
{{- if $math.mhchem -}}
{{- with $CDN.katexMhchemJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/katex/mhchem.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/katex/mhchem.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- end -}}
<script>
document.addEventListener("DOMContentLoaded", function () {
document.addEventListener('DOMContentLoaded', function () {
renderMathInElement(document.body, {
delimiters: [
{ left: "$", right: "$", display: false },
{ left: "$$", right: "$$", display: true },
{ left: "\\(", right: "\\)", display: false },
{ left: "\\[", right: "\\]", display: true },
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
{ left: "{{ $math.inlineLeftDelimiter }}", right: "{{ $math.inlineRightDelimiter }}", display: false },
{{- end -}}
{ left: '$$', right: '$$', display: true },
{ left: '\\[', right: '\\]', display: true },
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
{ left: "{{ $math.blockLeftDelimiter }}", right: "{{ $math.blockRightDelimiter }}", display: true },
{ 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 -}}
]
});
@@ -107,54 +151,54 @@
{{- end -}}
{{- /* mermaid https://github.com/knsv/mermaid */ -}}
{{- with .Scratch.Get "mermaidMap" -}}
{{- with $scratch.Get "mermaidMap" -}}
{{- with $CDN.mermaidJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/mermaid/mermaid.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/mermaid/mermaid.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- slice "css/mermaid.scss" | $.Scratch.Add "linkLocal" -}}
{{- slice "css/mermaid.scss" | $scratch.Add "linkLocal" -}}
<script>
window.mermaidMap = {{ jsonify . | safeJS }};
</script>
{{- end -}}
{{- /* Music */ -}}
{{- if .Scratch.Get "music" -}}
{{- if $scratch.Get "music" -}}
{{- /* APlayer https://github.com/MoePlayer/APlayer */ -}}
{{- with $CDN.aplayerCSS -}}
{{- slice . | $.Scratch.Add "linkCDN" -}}
{{- slice . | $scratch.Add "linkCDN" -}}
{{- else -}}
{{- slice "css/lib/aplayer/APlayer.min.css" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/aplayer/APlayer.min.css" | $scratch.Add "linkLocal" -}}
{{- end -}}
{{- slice "css/lib/aplayer/dark.scss" | .Scratch.Add "linkLocal" -}}
{{- slice "css/lib/aplayer/dark.scss" | $scratch.Add "linkLocal" -}}
{{- with $CDN.aplayerJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/aplayer/APlayer.min.js" | .Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/aplayer/APlayer.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* MetingJS https://github.com/metowolf/MetingJS */ -}}
{{- with $CDN.metingJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/meting/Meting.min.js" | .Scratch.Add "scriptLocal" -}}
{{- 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" -}}
{{- with $scratch.Get "echartsMap" -}}
{{- with $CDN.echartsJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/echarts/echarts.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/echarts/echarts.min.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
{{- with $CDN.echartsMacaronsJS -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- slice . | $scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/echarts/macarons.js" | $.Scratch.Add "scriptLocal" -}}
{{- slice "js/lib/echarts/macarons.js" | $scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
window.echartsMap = {
@@ -166,10 +210,10 @@
{{- end -}}
{{- end -}}
{{- range .Scratch.Get "linkCDN" -}}
{{- range $scratch.Get "linkCDN" -}}
{{- safeHTML . -}}
{{- end -}}
{{- range .Scratch.Get "linkLocal" -}}
{{- range $scratch.Get "linkLocal" -}}
{{- $res := resources.Get . -}}
{{- if strings.HasSuffix . ".scss" -}}
{{- $options := dict "outputStyle" "compressed" "enableSourceMap" true -}}
@@ -180,10 +224,10 @@
<link rel="stylesheet" href="{{ $res.RelPermalink }}">
{{- end -}}
{{- range .Scratch.Get "scriptCDN" -}}
{{- range $scratch.Get "scriptCDN" -}}
{{- safeHTML . -}}
{{- end -}}
{{- range .Scratch.Get "scriptLocal" -}}
{{- range $scratch.Get "scriptLocal" -}}
{{- $res := resources.Get . -}}
{{- if not (strings.HasSuffix . ".min.js") -}}
{{- $res = minify $res -}}
@@ -195,6 +239,6 @@
<script src=/js/theme.min.js></script>
{{- /* Google analytics async */ -}}
{{- if .Scratch.Get "production" | and .Site.GoogleAnalytics -}}
{{- if $scratch.Get "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}

View File

@@ -28,11 +28,9 @@
{{- end -}}
</div>
<div class="post-info-share">
{{- if .Site.Params.page.socialShare -}}
<span>
{{- partial "plugin/share.html" . -}}
</span>
{{- end -}}
<span>
{{- partial "plugin/share.html" . -}}
</span>
</div>
</div>
</div>