Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDillon <dillonzq@outlook.com>2020-02-24 12:00:39 +0300
committerDillon <dillonzq@outlook.com>2020-02-24 12:00:39 +0300
commit72a2e9bdcfee2daba6503cd473609d5ea34f2b30 (patch)
tree33292ea63e924455f7da15883952b19874583e80 /layouts
parentfbfcbaebcab2cfc8a65cdbdf1dc50c871320b3ac (diff)
feat(image): add image lightgallery
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/_markup/render-image.html5
-rw-r--r--layouts/_default/baseof.html6
-rw-r--r--layouts/_default/single.html2
-rw-r--r--layouts/_default/summary.html2
-rw-r--r--layouts/partials/comment.html24
-rw-r--r--layouts/partials/head/link.html3
-rw-r--r--layouts/partials/home/profile.html14
-rw-r--r--layouts/partials/paginator.html4
-rw-r--r--layouts/partials/plugin/icon.html4
-rw-r--r--layouts/partials/plugin/image.html39
-rw-r--r--layouts/partials/plugin/share.html12
-rw-r--r--layouts/partials/plugin/social.html10
-rw-r--r--layouts/partials/script.html172
-rw-r--r--layouts/partials/single/footer.html8
-rw-r--r--layouts/posts/single.html7
-rw-r--r--layouts/shortcodes/dev/echarts.html6
-rw-r--r--layouts/shortcodes/mermaid.html4
-rw-r--r--layouts/shortcodes/music.html4
-rw-r--r--layouts/shortcodes/typeit.html6
19 files changed, 212 insertions, 120 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 5f27a8c..5f8de9e 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -1,6 +1,7 @@
<figure>
- {{- partial "plugin/image.html" (dict "src" .Destination "alt" .Text "title" .Title ) -}}
- {{- with .Title | default .Text -}}
+ {{- $lightgallery := ne .Page.Site.Params.page.lightgallery false | and (ne .Page.Params.lightgallery false) -}}
+ {{- partial "plugin/image.html" (dict "src" .Destination "title" .Title "description" .Text "lightgallery" $lightgallery "context" .Page) -}}
+ {{- with (.Title | default .Text) -}}
<figcaption class="image-caption">
{{- . | safeHTML -}}
</figcaption>
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index d6ffa15..637135b 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -3,9 +3,11 @@
{{- errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/dillonzq/LoveIt#installation \n 2. You have an incompatible update. See https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/dillonzq/LoveIt#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n" -}}
{{- end -}}
+{{- $scratch := newScratch -}}
+{{- .Scratch.Set "scratch" $scratch -}}
{{- if eq (getenv "HUGO_ENV") "production" -}}
- {{- .Scratch.Set "production" true -}}
- {{- .Scratch.Set "CDN" .Site.Params.cdn -}}
+ {{- $scratch.Set "production" true -}}
+ {{- $scratch.Set "CDN" .Site.Params.cdn -}}
{{- end -}}
<!DOCTYPE html>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 13e3e21..5bdc32e 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -8,7 +8,7 @@
</h1>
{{- /* Content */ -}}
- <div class="content">
+ <div class="content" id="content">
{{- partial "single/content.html" .Content -}}
</div>
</div>
diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html
index 5df7211..d3fb3df 100644
--- a/layouts/_default/summary.html
+++ b/layouts/_default/summary.html
@@ -3,7 +3,7 @@
{{- with .Params.featuredImage -}}
<div class="featured-image-preview">
{{- $image := $.Params.featuredImagePreview | default . -}}
- {{- partial "plugin/image.html" (dict "src" $image "alt" "featured image") -}}
+ {{- partial "plugin/image.html" (dict "src" $image "description" $.Description "context" $) -}}
</div>
{{- end -}}
diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html
index 330c5cf..56c087a 100644
--- a/layouts/partials/comment.html
+++ b/layouts/partials/comment.html
@@ -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>
diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html
index 3ddcc2e..8e627f2 100644
--- a/layouts/partials/head/link.html
+++ b/layouts/partials/head/link.html
@@ -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" />
diff --git a/layouts/partials/home/profile.html b/layouts/partials/home/profile.html
index 4f15817..bdeff75 100644
--- a/layouts/partials/home/profile.html
+++ b/layouts/partials/home/profile.html
@@ -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 -}}
diff --git a/layouts/partials/paginator.html b/layouts/partials/paginator.html
index 24902ce..170144f 100644
--- a/layouts/partials/paginator.html
+++ b/layouts/partials/paginator.html
@@ -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) -}}
diff --git a/layouts/partials/plugin/icon.html b/layouts/partials/plugin/icon.html
index b65f1fa..85b258e 100644
--- a/layouts/partials/plugin/icon.html
+++ b/layouts/partials/plugin/icon.html
@@ -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>
diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html
index 7de83d3..b1749a6 100644
--- a/layouts/partials/plugin/image.html
+++ b/layouts/partials/plugin/image.html
@@ -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 -}}
diff --git a/layouts/partials/plugin/share.html b/layouts/partials/plugin/share.html
index d75b6fb..7d10c78 100644
--- a/layouts/partials/plugin/share.html
+++ b/layouts/partials/plugin/share.html
@@ -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 -}}
diff --git a/layouts/partials/plugin/social.html b/layouts/partials/plugin/social.html
index b74cd5c..f7eb995 100644
--- a/layouts/partials/plugin/social.html
+++ b/layouts/partials/plugin/social.html
@@ -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 -}}
diff --git a/layouts/partials/script.html b/layouts/partials/script.html
index e9a0e26..b74b3ec 100644
--- a/layouts/partials/script.html
+++ b/layouts/partials/script.html
@@ -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 -}}
diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html
index 93b4081..ddadaef 100644
--- a/layouts/partials/single/footer.html
+++ b/layouts/partials/single/footer.html
@@ -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>
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index bacdb8b..3330f22 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -1,6 +1,7 @@
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
{{- define "content" -}}
+ {{- $scratch := .Scratch.Get "scratch" -}}
<article class="page single">
{{- /* Title */ -}}
<h1 class="single-title animated flipInX">{{ .Title }}</h1>
@@ -35,7 +36,7 @@
<i class="far fa-calendar-alt fa-fw"></i><time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
<i class="fas fa-pencil-alt fa-fw"></i>{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock fa-fw"></i>{{ T "readingTime" .ReadingTime }}&nbsp;
- {{- if .Scratch.Get "production" | and .Site.Params.valine.enable | and .Site.Params.valine.visitor -}}
+ {{- if $scratch.Get "production" | and .Site.Params.valine.enable | and .Site.Params.valine.visitor -}}
<span id="{{ .RelPermalink | relURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i>{{ T "pageviews" | safeHTML }}
</span>&nbsp;
@@ -46,7 +47,7 @@
{{- /* Featured image */ -}}
{{- with .Params.featuredImage -}}
<div class="featured-image">
- {{- partial "plugin/image.html" (dict "src" . "alt" "featured image") -}}
+ {{- partial "plugin/image.html" (dict "src" . "description" $.Description "context" $) -}}
</div>
{{- end -}}
@@ -76,7 +77,7 @@
{{- end -}}
{{- /* Content */ -}}
- <div class="content">
+ <div class="content" id="content">
{{- partial "single/content.html" .Content -}}
</div>
diff --git a/layouts/shortcodes/dev/echarts.html b/layouts/shortcodes/dev/echarts.html
index c1cb06b..ad967bd 100644
--- a/layouts/shortcodes/dev/echarts.html
+++ b/layouts/shortcodes/dev/echarts.html
@@ -1,4 +1,6 @@
-<!-- shuffle md5 as id -->
+{{- $scratch := .Page.Scratch.Get "scratch" -}}
+
+{{- /* shuffle md5 as id */ -}}
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "echarts-%s" -}}
<div class="echarts" id="{{ $id }}"></div>
-{{- .Page.Scratch.SetInMap "echartsMap" $id (printf "{%s}" .Inner) -}}
+{{- $scratch.SetInMap "echartsMap" $id (printf "{%s}" .Inner) -}}
diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html
index f513850..1d13be1 100644
--- a/layouts/shortcodes/mermaid.html
+++ b/layouts/shortcodes/mermaid.html
@@ -1,4 +1,6 @@
+{{- $scratch := .Page.Scratch.Get "scratch" -}}
+
{{- /* shuffle md5 as id */ -}}
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
<div class="mermaid" id="{{ $id }}"></div>
-{{- .Page.Scratch.SetInMap "mermaidMap" $id (trim .Inner "\n") -}}
+{{- $scratch.SetInMap "mermaidMap" $id (trim .Inner "\n") -}}
diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html
index f84d2d5..dcd98ba 100644
--- a/layouts/shortcodes/music.html
+++ b/layouts/shortcodes/music.html
@@ -1,3 +1,5 @@
+{{- $scratch := .Page.Scratch.Get "scratch" -}}
+
{{- if .IsNamedParams -}}
<meting-js server="{{ .Get "server" }}" type="{{ .Get "type" }}" id="{{ .Get "id" }}" theme="#A9A9B3"
{{- with .Get "autoplay" }} autoplay="{{ . }}"{{ end -}}
@@ -9,4 +11,4 @@
{{- else -}}
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="#A9A9B3"></meting-js>
{{- end -}}
-{{- .Page.Scratch.Set "music" true -}}
+{{- $scratch.Set "music" true -}}
diff --git a/layouts/shortcodes/typeit.html b/layouts/shortcodes/typeit.html
index 95c2ac1..80d384c 100644
--- a/layouts/shortcodes/typeit.html
+++ b/layouts/shortcodes/typeit.html
@@ -1,3 +1,5 @@
+{{- $scratch := .Page.Scratch.Get "scratch" -}}
+
{{- /* only the trailing newline is retained */ -}}
{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString -}}
{{- /* shuffle md5 as id */ -}}
@@ -35,7 +37,7 @@
{{- end -}}
{{- $key := .Get "group" | default $id -}}
- {{- $group := index (.Page.Scratch.Get "typeitMap" | default dict) $key -}}
+ {{- $group := index ($scratch.Get "typeitMap" | default dict) $key -}}
{{- $group = $group | default slice | append $id -}}
- {{- .Page.Scratch.SetInMap "typeitMap" $key $group -}}
+ {{- $scratch.SetInMap "typeitMap" $key $group -}}
</div>