diff options
author | Dillon <dillonzq@outlook.com> | 2020-03-08 16:02:21 +0300 |
---|---|---|
committer | Dillon <dillonzq@outlook.com> | 2020-03-08 16:02:21 +0300 |
commit | 296424cded8ad1d548f7e3f891ef1f492b3f85b6 (patch) | |
tree | 242e33b08f2538e4c5341e39d730d1a6f479de8e /layouts | |
parent | b1f2de1987507c5c9f757b6da7bfb0593ebd3804 (diff) |
feature(doc): complete all Chinese and English documents and fix many bugs
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-image.html | 13 | ||||
-rw-r--r-- | layouts/_default/section.html | 4 | ||||
-rw-r--r-- | layouts/_default/summary.html | 2 | ||||
-rw-r--r-- | layouts/partials/assets.html | 15 | ||||
-rw-r--r-- | layouts/partials/comment.html | 2 | ||||
-rw-r--r-- | layouts/partials/footer.html | 2 | ||||
-rw-r--r-- | layouts/partials/function/checkbox.html | 12 | ||||
-rw-r--r-- | layouts/partials/function/escape.html | 5 | ||||
-rw-r--r-- | layouts/partials/function/id.html | 4 | ||||
-rw-r--r-- | layouts/partials/header.html | 8 | ||||
-rw-r--r-- | layouts/partials/plugin/icon.html | 8 | ||||
-rw-r--r-- | layouts/partials/plugin/image.html | 5 | ||||
-rw-r--r-- | layouts/partials/plugin/share.html | 58 | ||||
-rw-r--r-- | layouts/partials/single/content.html | 2 | ||||
-rw-r--r-- | layouts/partials/single/footer.html | 2 | ||||
-rw-r--r-- | layouts/posts/single.html | 6 | ||||
-rw-r--r-- | layouts/shortcodes/admonition.html | 30 | ||||
-rw-r--r-- | layouts/shortcodes/bilibili.html | 4 | ||||
-rw-r--r-- | layouts/shortcodes/image.html | 8 | ||||
-rw-r--r-- | layouts/shortcodes/music.html | 44 | ||||
-rw-r--r-- | layouts/shortcodes/typeit.html | 55 |
21 files changed, 163 insertions, 126 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 7c7e389..cfe5ed3 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,9 +1,10 @@ -<figure> - {{- $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 "scratch" (.Page.Scratch.Get "scratch")) -}} - {{- with (.Title | default .Text) -}} +{{- with .Title -}} + <figure> + {{- partial "plugin/image.html" (dict "src" $.Destination "title" $.Title "description" $.Text "lightgallery" true "scratch" ($.Page.Scratch.Get "scratch")) -}} <figcaption class="image-caption"> {{- . | safeHTML -}} </figcaption> - {{- end -}} -</figure> + </figure> +{{- else -}} + {{- partial "plugin/image.html" (dict "src" .Destination "title" .Title "description" .Text "lightgallery" false "scratch" (.Page.Scratch.Get "scratch")) -}} +{{- end -}} diff --git a/layouts/_default/section.html b/layouts/_default/section.html index 5b1bf19..415314b 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -1,12 +1,12 @@ {{- define "title" }} - {{- T "all" | humanize}}{{ T .Section | default .Section | humanize }} | {{ .Site.Title -}} + {{- T .Section | default .Section | printf (T "allSome") }} | {{ .Site.Title -}} {{- end -}} {{- define "content" -}} <div class="page archive"> {{- /* Title */ -}} <h2 class="single-title animated pulse faster"> - {{- T "all" | humanize}}{{ T .Section | default .Section | humanize -}} + {{- T .Section | default .Section | humanize | printf (T "allSome") -}} </h2> {{- /* Paginate */ -}} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 0fe2c7d..ee74fc7 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -16,7 +16,7 @@ {{- /* Meta */ -}} <div class="post-meta"> - {{- $author := .Params.author | default .Site.Author.name -}} + {{- $author := .Params.author | default .Site.Author.name | default (T "author") -}} {{- $authorLink := .Params.authorLink | default .Site.Author.link | default (relLangURL "/") -}} <span class="post-author"> <a class="author" href="{{ $authorLink }}" rel="author" target="_blank"> diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 9a0d4e4..aa901c5 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -28,16 +28,14 @@ {{- end -}} {{- /* lazysizes */ -}} -{{- if $scratch.Get "lazysizes" -}} - {{- with $CDN.lazysizesJS -}} - {{- slice . | $scratch.Add "scriptCDN" -}} - {{- else -}} - {{- slice "lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}} - {{- end -}} +{{- with $CDN.lazysizesJS -}} + {{- slice . | $scratch.Add "scriptCDN" -}} +{{- else -}} + {{- slice "lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}} {{- end -}} {{- /* lightgallery.js */ -}} -{{- if $scratch.Get "lightgallery" -}} +{{- if ne .Page.Site.Params.page.lightgallery false | and (ne .Page.Params.lightgallery false) -}} {{- with $CDN.lightgalleryCSS -}} {{- slice . | $scratch.Add "linkCDN" -}} {{- else -}} @@ -139,7 +137,8 @@ {{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}} { left: '{{ $math.inlineLeftDelimiter }}', right: '{{ $math.inlineRightDelimiter }}', display: false }, {{- end -}} - ] + ], + strict: false, }); }); </script> diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index cb2970f..14b2cf4 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -81,7 +81,7 @@ {{- with $valine.pageSize -}} pageSize: {{ . | safeJS }}, {{- end -}} - lang: '{{ T "valineLang" }}', + lang: '{{ $valine.lang | default "en" }}', {{- if $valine.visitor -}} visitor: true, {{- end -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 22cda9e..22bdd65 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -2,7 +2,7 @@ <div class="copyright"> {{- /* Hugo and LoveIt */ -}} <div class="copyright-line"> - {{- printf (T "powered") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>` | safeHTML }} | {{ T "theme" }}<a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer">LoveIt<i class="far fa-heart fa-fw"></i></a> + {{- printf (T "poweredBySome") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>` | safeHTML }} | {{ T "theme" }} - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer">LoveIt<i class="far fa-heart fa-fw"></i></a> </div> <div class="copyright-line"> diff --git a/layouts/partials/function/checkbox.html b/layouts/partials/function/checkbox.html index 7d39720..2283592 100644 --- a/layouts/partials/function/checkbox.html +++ b/layouts/partials/function/checkbox.html @@ -1,9 +1,9 @@ {{- /* Checkbox unchecked */ -}} -{{- $REin := `<input disabled="" type="checkbox">` -}} -{{- $REout := `<i class="far fa-square fa-fw"></i>` -}} -{{- $content := replaceRE $REin $REout . -}} +{{- $old := `<input disabled="" type="checkbox">` -}} +{{- $new := `<i class="far fa-square fa-fw"></i>` -}} +{{- $content := replace . $old $new -}} {{- /* Checkbox checked */ -}} -{{- $REin = `<input checked="" disabled="" type="checkbox">` -}} -{{- $REout = `<i class="far fa-check-square fa-fw"></i>` -}} -{{- return replaceRE $REin $REout $content -}} +{{- $old = `<input checked="" disabled="" type="checkbox">` -}} +{{- $new = `<i class="far fa-check-square fa-fw"></i>` -}} +{{- return replace $content $old $new -}} diff --git a/layouts/partials/function/escape.html b/layouts/partials/function/escape.html new file mode 100644 index 0000000..1ff794f --- /dev/null +++ b/layouts/partials/function/escape.html @@ -0,0 +1,5 @@ +{{- /* Escape character */ -}} +{{- /* {?X} -> X */ -}} +{{- $REin := `\{\?(.)\}` -}} +{{- $REout := `$1` -}} +{{- return replaceRE $REin $REout . -}} diff --git a/layouts/partials/function/id.html b/layouts/partials/function/id.html index 081fc67..c702908 100644 --- a/layouts/partials/function/id.html +++ b/layouts/partials/function/id.html @@ -2,5 +2,7 @@ {{- /* Content -> unique ID */ -}} {{- /* shuffle md5 as id */ -}} {{- $id := delimit (split (md5 now.Unix) "" | shuffle | first 6) "" | printf "id-%s" -}} -{{- .scratch.SetInMap "contentMap" $id .content -}} +{{- with .scratch -}} + {{- .SetInMap "contentMap" $id $.content -}} +{{- end -}} {{- return $id -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index e938b67..d4b0951 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -14,7 +14,7 @@ {{- end -}} {{- if .Site.IsMultiLingual -}} | - <span class="menu-item"> + <a href="javascript:void(0);" class="menu-item"> <i class="fas fa-language fa-fw"></i> <select class="select-language" onchange="location = this.value;"> {{- range .Page.AllTranslations -}} @@ -30,7 +30,7 @@ {{- end -}} {{- end -}} </select> - </span> + </a> {{- end -}} <a href="javascript:void(0);" class="theme-switch" title="{{ T "switchTheme" }}"> <i class="fas fa-adjust fa-rotate-180 fa-fw"></i> @@ -60,7 +60,7 @@ </a> {{- end -}} {{- if .Site.IsMultiLingual -}} - <span class="menu-item"> + <a href="javascript:void(0);" class="menu-item"> <i class="fas fa-language fa-fw"></i> <select class="select-language" onchange="location = this.value;"> {{- range .Page.AllTranslations -}} @@ -76,7 +76,7 @@ {{- end -}} {{- end -}} </select> - </span> + </a> {{- end -}} <a href="javascript:void(0);" class="theme-switch" title="{{ T "switchTheme" }}"> <i class="fas fa-adjust fa-rotate-180 fa-fw"></i> diff --git a/layouts/partials/plugin/icon.html b/layouts/partials/plugin/icon.html index 6ed4061..9898a08 100644 --- a/layouts/partials/plugin/icon.html +++ b/layouts/partials/plugin/icon.html @@ -11,11 +11,15 @@ {{- end -}} {{- end -}} {{- $classList = $newClassList -}} - {{- .scratch.Set "forkawesome" true -}} + {{- with .scratch -}} + {{- .Set "forkawesome" true -}} + {{- end -}} {{- /* default is Font Awesome */ -}} {{- /* Others */ -}} {{- else if ne $type "fa" -}} - {{- .scratch.Set "iconfont" true -}} + {{- with .scratch -}} + {{- .Set "iconfont" true -}} + {{- end -}} {{- end -}} <i class="{{ delimit $classList ` ` }}"></i> diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 18e8e59..99a698d 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -15,7 +15,9 @@ data-src="{{ .src | safeURL }}" alt="{{ .title | default .description }}" /> </a> - {{- .scratch.Set "lightgallery" true -}} + {{- with .scratch -}} + {{- .Set "lightgallery" true -}} + {{- end -}} {{- else -}} <img class="lazyload" @@ -26,4 +28,3 @@ 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 4996fb8..08eba8f 100644 --- a/layouts/partials/plugin/share.html +++ b/layouts/partials/plugin/share.html @@ -1,200 +1,200 @@ {{- $scratch := .Scratch.Get "scratch" -}} -{{- if ne .Site.Params.share.enable false | and (ne .Params.share false) -}} +{{- if ne .Site.Params.share.enable false | and (ne .Params.share.enable false) -}} {{- $scratch.Set "share" true -}} {{- /* 001: Twitter */ -}} {{- if .Params.Share.Twitter | default .Site.Params.Share.Twitter | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Twitter" data-sharer="twitter" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Site.Params.Social.Twitter }} data-via="{{ . }}"{{ end }}{{ with .Params.tags }} data-hashtags="{{ delimit . `,` }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Twitter" data-sharer="twitter" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Site.Params.Social.Twitter }} data-via="{{ . }}"{{ end }}{{ with .Params.tags }} data-hashtags="{{ delimit . `,` }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-twitter fa-fw") -}} </a> {{- end -}} {{- /* 002: Facebook */ -}} {{- if .Params.Share.Facebook | default .Site.Params.Share.Facebook | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Facebook" data-sharer="facebook" data-url="{{ .Permalink }}"{{ with .Params.tags }} data-hashtag="{{ index . 0 }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Facebook" data-sharer="facebook" data-url="{{ .Permalink }}"{{ with .Params.tags }} data-hashtag="{{ index . 0 }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-facebook-square fa-fw") -}} </a> {{- end -}} {{- /* 003: Linkedin */ -}} {{- if .Params.Share.Linkedin | default .Site.Params.Share.Linkedin | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Linkedin" data-sharer="linkedin" data-url="{{ .Permalink }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Linkedin" data-sharer="linkedin" data-url="{{ .Permalink }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-linkedin fa-fw") -}} </a> {{- end -}} {{- /* 004: WhatsApp */ -}} {{- if .Params.Share.Whatsapp | default .Site.Params.Share.Whatsapp | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} WhatsApp" data-sharer="whatsapp" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-web> + <a href="javascript:void(0);" title="{{ T `shareOn` }} WhatsApp" data-sharer="whatsapp" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-web> {{- partial "plugin/icon.html" (dict "class" "fab fa-whatsapp fa-fw") -}} </a> {{- end -}} {{- /* 005: Viber */ -}} {{- if .Params.Share.Viber | default .Site.Params.Share.Viber | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Viber" data-sharer="viber" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Viber" data-sharer="viber" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-viber fa-fw") -}} </a> {{- end -}} {{- /* 006: Pinterest */ -}} {{- if .Params.Share.Pinterest | default .Site.Params.Share.Pinterest | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Pinterest" data-sharer="pinterest" data-url="{{ .Permalink }}"{{ with .Description }} data-description="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Pinterest" data-sharer="pinterest" data-url="{{ .Permalink }}"{{ with .Description }} data-description="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-pinterest fa-fw") -}} </a> {{- end -}} {{- /* 007: Tumblr */ -}} {{- if .Params.Share.Tumblr | default .Site.Params.Share.Tumblr | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Tumblr" data-sharer="tumblr" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with .Params.tags }} data-tags="{{ delimit . `,` }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Tumblr" data-sharer="tumblr" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with .Params.tags }} data-tags="{{ delimit . `,` }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-tumblr fa-fw") -}} </a> {{- end -}} {{- /* 008: Hacker News */ -}} {{- if .Params.Share.Hackernews | default .Site.Params.Share.Hackernews | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Hacker News" data-sharer="hackernews" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Hacker News" data-sharer="hackernews" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-hacker-news fa-fw") -}} </a> {{- end -}} {{- /* 009: Reddit */ -}} {{- if .Params.Share.Reddit | default .Site.Params.Share.Reddit | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Reddit" data-sharer="reddit" data-url="{{ .Permalink }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Reddit" data-sharer="reddit" data-url="{{ .Permalink }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-reddit fa-fw") -}} </a> {{- end -}} {{- /* 010: VK */ -}} {{- if .Params.Share.VK | default .Site.Params.Share.VK | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} VK" data-sharer="vk" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} VK" data-sharer="vk" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-vk fa-fw") -}} </a> {{- end -}} {{- /* 011: Buffer */ -}} {{- if .Params.Share.Buffer | default .Site.Params.Share.Buffer | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Buffer" data-sharer="buffer" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Site.Params.Social.Twitter }} data-via="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-picture="{{ . }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Buffer" data-sharer="buffer" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Site.Params.Social.Twitter }} data-via="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-picture="{{ . }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-buffer fa-fw") -}} </a> {{- end -}} {{- /* 012: Xing */ -}} {{- if .Params.Share.Xing | default .Site.Params.Share.Xing | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Xing" data-sharer="xing" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Xing" data-sharer="xing" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-xing fa-fw") -}} </a> {{- end -}} {{- /* 013: Line */ -}} {{- if .Params.Share.Line | default .Site.Params.Share.Line | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Line" data-sharer="line" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Line" data-sharer="line" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-line fa-fw") -}} </a> {{- end -}} {{- /* 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 }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} 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) -}} </a> {{- end -}} {{- /* 015: Pocket */ -}} {{- if .Params.Share.Pocket | default .Site.Params.Share.Pocket | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Pocket" data-sharer="pocket" data-url="{{ .Permalink }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Pocket" data-sharer="pocket" data-url="{{ .Permalink }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-get-pocket fa-fw") -}} </a> {{- end -}} {{- /* 016: Digg */ -}} {{- if .Params.Share.Digg | default .Site.Params.Share.Digg | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Digg" data-sharer="digg" data-url="{{ .Permalink }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Digg" data-sharer="digg" data-url="{{ .Permalink }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-digg fa-fw") -}} </a> {{- end -}} {{- /* 017: StumbleUpon */ -}} {{- if .Params.Share.Stumbleupon | default .Site.Params.Share.Stumbleupon | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} StumbleUpon" data-sharer="stumbleupon" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} StumbleUpon" data-sharer="stumbleupon" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-stumbleupon fa-fw") -}} </a> {{- end -}} {{- /* 018: Flipboard */ -}} {{- if .Params.Share.Flipboard | default .Site.Params.Share.Flipboard | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Flipboard" data-sharer="flipboard" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Flipboard" data-sharer="flipboard" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-flipboard fa-fw") -}} </a> {{- end -}} {{- /* 019: 微博 */ -}} {{- if .Params.Share.Weibo | default .Site.Params.Share.Weibo | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} 微博" data-sharer="weibo" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}{{ with .Site.Params.Social.Weibo }} data-ralateuid="{{ . }}"{{ end }}> + <a href="javascript:void(0);" title="{{ T `shareOn` }} 微博" data-sharer="weibo" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}{{ with .Site.Params.Social.Weibo }} data-ralateuid="{{ . }}"{{ end }}> {{- partial "plugin/icon.html" (dict "class" "fab fa-weibo fa-fw") -}} </a> {{- end -}} {{- /* 020: 人人 */ -}} {{- if .Params.Share.Renren | default .Site.Params.Share.Renren | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} 人人" data-sharer="renren" data-url="{{ .Permalink }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} 人人" data-sharer="renren" data-url="{{ .Permalink }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-renren fa-fw") -}} </a> {{- end -}} {{- /* 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 }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} 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) -}} </a> {{- end -}} {{- /* 022: Blogger */ -}} {{- if .Params.Share.Blogger | default .Site.Params.Share.Blogger | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Blogger" data-sharer="blogger" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Blogger" data-sharer="blogger" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-blogger fa-fw") -}} </a> {{- end -}} {{- /* 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 }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} 百度" data-sharer="baidu" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "loveit it-baidu-fill" "type" "other" "scratch" $scratch) -}} </a> {{- end -}} {{- /* 024: OK.RU */ -}} {{- if .Params.Share.Odnoklassniki | default .Site.Params.Share.Odnoklassniki | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} OK.RU" data-sharer="okru" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} OK.RU" data-sharer="okru" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-odnoklassniki fa-fw") -}} </a> {{- end -}} {{- /* 025: Evernote */ -}} {{- if .Params.Share.Evernote | default .Site.Params.Share.Evernote | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Evernote" data-sharer="evernote" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Evernote" data-sharer="evernote" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-evernote fa-fw") -}} </a> {{- end -}} {{- /* 026: Skype */ -}} {{- if .Params.Share.Skype | default .Site.Params.Share.Skype | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Skype" data-sharer="skype" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Skype" data-sharer="skype" data-url="{{ .Permalink }}" data-title="{{ .Title }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-skype fa-fw") -}} </a> {{- end -}} {{- /* 027: Trello */ -}} {{- if .Params.Share.Trello | default .Site.Params.Share.Trello | eq true -}} - <a href="javascript:void(0);" title="{{ T `share` }} Trello" data-sharer="trello" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}"> + <a href="javascript:void(0);" title="{{ T `shareOn` }} Trello" data-sharer="trello" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}"> {{- partial "plugin/icon.html" (dict "class" "fab fa-trello fa-fw") -}} </a> {{- end -}} {{- /* 028: Mix */ -}} {{- if .Params.Share.Mix | default .Site.Params.Share.Mix | eq true -}} - <a href="//mix.com/add?url={{ .Permalink }}&description={{ .Title }}" target="_blank" title="{{ T `share` }} Mix"> + <a href="//mix.com/add?url={{ .Permalink }}&description={{ .Title }}" target="_blank" title="{{ T `shareOn` }} Mix"> {{- partial "plugin/icon.html" (dict "class" "fab fa-mix fa-fw") -}} </a> {{- end -}} diff --git a/layouts/partials/single/content.html b/layouts/partials/single/content.html index c0327ca..efab566 100644 --- a/layouts/partials/single/content.html +++ b/layouts/partials/single/content.html @@ -6,4 +6,6 @@ {{- $content = partial "function/checkbox.html" $content -}} +{{- $content = partial "function/escape.html" $content -}} + {{- $content | safeHTML -}} diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index 7727ef7..af0efeb 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -23,7 +23,7 @@ </div> <div class="post-info-line"> <div class="post-info-md"> - {{- if .Site.Params.page.linkToMarkdown -}} + {{- if ne .Site.Params.page.linkToMarkdown false | and (ne .Params.linkToMarkdown false) -}} {{- with .OutputFormats.Get "markdown" -}} <span> <a class="link-to-markdown" href="{{ .Permalink }}" target="_blank"> diff --git a/layouts/posts/single.html b/layouts/posts/single.html index affe4c2..25ffb07 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -9,7 +9,7 @@ {{- /* Meta */ -}} <div class="post-meta"> <div class="post-meta-line"> - {{- $author := .Params.author | default .Site.Author.name -}} + {{- $author := .Params.author | default .Site.Author.name | default (T "author") -}} {{- $authorLink := .Params.authorLink | default .Site.Author.link | default (relLangURL "/") -}} <span class="post-author"> <a class="author" href="{{ $authorLink }}" rel="author" target="_blank"> @@ -54,7 +54,7 @@ {{- /* TOC */ -}} {{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}} <div class="toc" id="toc-auto"> - <h2 class="toc-title">{{ T "toc" }}</h2> + <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> @@ -62,7 +62,7 @@ <details> <summary> <div class="toc-title"> - <span>{{ T "toc" }}</span> + <span>{{ T "contents" }}</span> <span><i class="details icon fas fa-angle-down"></i></span> </div> </summary> diff --git a/layouts/shortcodes/admonition.html b/layouts/shortcodes/admonition.html index 334a505..08123e9 100644 --- a/layouts/shortcodes/admonition.html +++ b/layouts/shortcodes/admonition.html @@ -16,45 +16,37 @@ {{- if .IsNamedParams -}} {{- $type := .Get "type" | default "note" -}} - {{- if eq (.Get "details") "true" -}} + {{- if .Get "details" -}} <details class="admonition {{ $type }}"> - {{- with .Get "title" -}} - <summary class="admonition-title"> - <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i> - </summary> - {{- end -}} + <summary class="admonition-title"> + <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}<i class="details {{ $iconDetails }}"></i> + </summary> <div class="admonition-content"> {{- $inner -}} </div> </details> {{- else -}} <div class="admonition {{ $type }}"> - {{- with .Get "title" -}} - <p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p> - {{- end -}} + <p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}</p> <div class="admonition-content"> {{- $inner -}} </div> </div> {{- end -}} {{- else -}} - {{- $type := .Get 0 -}} - {{- if eq (.Get 2) "true" -}} + {{- $type := .Get 0 | default "note" -}} + {{- if .Get 2 -}} <details class="admonition {{ $type }}"> - {{- with .Get 1 -}} - <summary class="admonition-title"> - <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i> - </summary> - {{- end -}} + <summary class="admonition-title"> + <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}<i class="details {{ $iconDetails }}"></i> + </summary> <div class="admonition-content"> {{- $inner -}} </div> </details> {{- else -}} <div class="admonition {{ $type }}"> - {{- with .Get 1 -}} - <p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p> - {{- end -}} + <p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}</p> <div class="admonition-content"> {{- $inner -}} </div> diff --git a/layouts/shortcodes/bilibili.html b/layouts/shortcodes/bilibili.html index 128e2d5..0bb2b17 100644 --- a/layouts/shortcodes/bilibili.html +++ b/layouts/shortcodes/bilibili.html @@ -1,7 +1,7 @@ <div class="bilibili"> {{- if .IsNamedParams -}} - <iframe src="//player.bilibili.com/player.html?aid={{ .Get "aid" }}&cid={{ .Get "cid" }}&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe> + <iframe src="//player.bilibili.com/player.html?aid={{ .Get `av` }}&page={{ .Get `p` | default 1 }}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe> {{- else -}} - <iframe src="//player.bilibili.com/player.html?aid={{ .Get 0 }}&cid={{ .Get 1 }}&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe> + <iframe src="//player.bilibili.com/player.html?aid={{ .Get 0 }}&page={{ .Get 1 | default 1 }}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe> {{- end -}} </div> diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html index e2d4f77..4887b9d 100644 --- a/layouts/shortcodes/image.html +++ b/layouts/shortcodes/image.html @@ -2,13 +2,15 @@ {{- $options := .Get "src" | dict "src" -}} {{- $options = .Get "src_s" | dict "src_s" | merge $options -}} {{- $options = .Get "src_l" | dict "src_l" | merge $options -}} - {{- $options = .Get "title" | dict "title" | merge $options -}} - {{- $options = .Get "description" | dict "description" | merge $options -}} + {{- $title := .Get "title" | $.Page.RenderString -}} + {{- $options = $title | dict "title" | merge $options -}} + {{- $description := .Get "description" | $.Page.RenderString -}} + {{- $options = $description | dict "description" | merge $options -}} {{- $lightgallery := ne .Page.Site.Params.page.lightgallery false | and (ne .Page.Params.lightgallery false) -}} {{- $options = $lightgallery | dict "lightgallery" | merge $options -}} {{- $options = .Page.Scratch.Get "scratch" | dict "scratch" | merge $options -}} {{- partial "plugin/image.html" $options -}} - {{- with (.Get "title" | default .Get "description") -}} + {{- with $title | default $description -}} <figcaption class="image-caption"> {{- . | safeHTML -}} </figcaption> diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html index dcd98ba..ca8a51f 100644 --- a/layouts/shortcodes/music.html +++ b/layouts/shortcodes/music.html @@ -1,14 +1,42 @@ {{- $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 -}} - {{- with .Get "mini" }} mini="{{ . }}"{{ end -}} - {{- with .Get "fixed" }} fixed="{{ . }}"{{ end -}} - {{- with .Get "list-folded" }} list-folded="{{ . }}"{{ end -}} - {{- with .Get "list-max-height" }} list-max-height="{{ . }}"{{ end -}} - ></meting-js> + {{- if .Get "url" -}} + <meting-js url="{{ .Get `url` }}" name="{{ .Get `name` }}" artist="{{ .Get `artist` }}" cover="{{ .Get `cover` }}" theme="{{ .Get `theme` | default `#a9a9b3` }}" + {{- with .Get "fixed" }} fixed="{{ . }}"{{ end -}} + {{- with .Get "mini" }} mini="{{ . }}"{{ end -}} + {{- with .Get "autoplay" }} autoplay="{{ . }}"{{ end -}} + {{- with .Get "volume" }} volume="{{ . }}"{{ end -}} + {{- with .Get "mutex" }} mutex="{{ . }}"{{ end -}} + ></meting-js> + {{- else if .Get "auto" -}} + <meting-js auto="{{ .Get `auto` }}" theme="{{ .Get `theme` | default `#a9a9b3` }}" + {{- with .Get "fixed" }} fixed="{{ . }}"{{ end -}} + {{- with .Get "mini" }} mini="{{ . }}"{{ end -}} + {{- with .Get "autoplay" }} autoplay="{{ . }}"{{ end -}} + {{- with .Get "loop" }} loop="{{ . }}"{{ end -}} + {{- with .Get "order" }} order="{{ . }}"{{ end -}} + {{- with .Get "volume" }} volume="{{ . }}"{{ end -}} + {{- with .Get "mutex" }} mutex="{{ . }}"{{ end -}} + {{- with .Get "list-folded" }} list-folded="{{ . }}"{{ end -}} + {{- with .Get "list-max-height" }} list-max-height="{{ . }}"{{ end -}} + ></meting-js> + {{- else -}} + <meting-js server="{{ .Get `server` }}" type="{{ .Get `type` }}" id="{{ .Get `id` }}" theme="{{ .Get `theme` | default `#a9a9b3` }}" + {{- with .Get "fixed" }} fixed="{{ . }}"{{ end -}} + {{- with .Get "mini" }} mini="{{ . }}"{{ end -}} + {{- with .Get "autoplay" }} autoplay="{{ . }}"{{ end -}} + {{- with .Get "loop" }} loop="{{ . }}"{{ end -}} + {{- with .Get "order" }} order="{{ . }}"{{ end -}} + {{- with .Get "volume" }} volume="{{ . }}"{{ end -}} + {{- with .Get "mutex" }} mutex="{{ . }}"{{ end -}} + {{- with .Get "list-folded" }} list-folded="{{ . }}"{{ end -}} + {{- with .Get "list-max-height" }} list-max-height="{{ . }}"{{ end -}} + ></meting-js> + {{- end -}} +{{- else if strings.HasSuffix (.Get 0) "http" -}} + <meting-js auto="{{ .Get 0 }}" theme="#a9a9b3"></meting-js> {{- else -}} - <meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="#A9A9B3"></meting-js> + <meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="#a9a9b3"></meting-js> {{- end -}} {{- $scratch.Set "music" true -}} diff --git a/layouts/shortcodes/typeit.html b/layouts/shortcodes/typeit.html index 9176f0f..fdbecf1 100644 --- a/layouts/shortcodes/typeit.html +++ b/layouts/shortcodes/typeit.html @@ -1,32 +1,33 @@ {{- $scratch := .Page.Scratch.Get "scratch" -}} -{{- /* only the trailing newline is retained */ -}} -{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString | chomp -}} -{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}} +{{- $content := .Inner -}} +{{- $classList := .Get "class" | slice -}} +{{- $tag := .Get "tag" | default "div" -}} + +{{- with .Get "code" -}} + {{- /* highlight code content without line number */ -}} + {{- $content = highlight $content . "linenos=false" -}} + {{- /* delete outer label */ -}} + {{- $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content -}} + {{- /* parsing markdown links */ -}} + {{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content -}} + {{- /* replace " " to " " and replace "\n" to "<br />" */ -}} + {{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "<br />" -}} + {{- /* fix "<br />" location error which is a bug of Typeit HTML parser */ -}} + {{- $content = replaceRE `<br /></span>` "</span><br />" $content -}} + {{- $classList = $classList | append "highlight" -}} +{{- else -}} + {{- $content = $content | .Page.RenderString -}} +{{- end -}} -<div class={{ .Get "class" | default "typeit" }}> - {{- /* raw html content */ -}} - {{- if .Get "raw" -}} - <div id={{ $id }}></div> - {{- else if .Get "code" -}} - {{- /* highlight code content without line number */ -}} - {{- $content = highlight $content (.Get "code") "linenos=false" -}} - {{- /* delete outer label */ -}} - {{- $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content -}} - {{- /* parsing markdown links */ -}} - {{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content -}} - {{- /* replace " " to " " and replace "\n" to "<br />" */ -}} - {{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "<br />" -}} - {{- /* fix "<br />" location error which is a bug of Typeit HTML parser */ -}} - {{- $content = replaceRE `<br /></span>` "</span><br />" $content -}} - <div class="highlight" id={{ $id }}></div> - {{- else -}} - {{- $tag := .Get "tag" | default "p" -}} - {{- printf "<%s id=%s></%s>" $tag $id $tag | safeHTML -}} - {{- end -}} +{{- /* trim the newline */ -}} +{{- $content = trim $content "\n" -}} +{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}} +{{- $key := .Get "group" | default $id -}} +{{- $group := index ($scratch.Get "typeitMap" | default dict) $key -}} +{{- $group = $group | default slice | append $id -}} +{{- $scratch.SetInMap "typeitMap" $key $group -}} - {{- $key := .Get "group" | default $id -}} - {{- $group := index ($scratch.Get "typeitMap" | default dict) $key -}} - {{- $group = $group | default slice | append $id -}} - {{- $scratch.SetInMap "typeitMap" $key $group -}} +<div class="typeit"> + {{- printf `<%s id="%s" class="%s"></%s>` $tag $id (delimit $classList " ") $tag | safeHTML -}} </div> |