From ba4b506b2f3c9029c66516f71d6d11e55b6137eb Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 6 May 2024 16:00:29 +0800 Subject: [PATCH] Feat: use `strings.Title` for post title and other titles (#421) Closes #421 --- layouts/_default/section.html | 2 +- layouts/_default/single.html | 4 +- layouts/_default/single.md | 4 +- layouts/_default/summary.html | 2 +- layouts/index.archives.html | 2 +- layouts/page/friends.html | 4 +- layouts/partials/breadcrumb.html | 4 +- layouts/partials/plugin/share.html | 41 ++++++++++---------- layouts/partials/recently-updated.html | 2 +- layouts/partials/single/collection-list.html | 9 +++-- layouts/partials/single/collection-nav.html | 8 ++-- layouts/partials/single/footer.html | 8 ++-- layouts/partials/single/related.html | 3 +- layouts/posts/single.html | 31 ++++++++------- layouts/taxonomy/list.html | 2 +- layouts/taxonomy/terms/categories.html | 2 +- layouts/taxonomy/terms/collections.html | 2 +- 17 files changed, 67 insertions(+), 63 deletions(-) diff --git a/layouts/_default/section.html b/layouts/_default/section.html index 7d3f7525..7272b21e 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -49,7 +49,7 @@ {{- if eq $repost.enable true -}} {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}} {{- end -}} - {{- .LinkTitle -}} + {{- title .LinkTitle -}} {{- .Date | dateFormat ($.Site.Params.section.dateFormat | default "01-02") -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 81fea5e6..96337ad1 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,5 +1,5 @@ {{- define "title" -}} - {{- .Title -}} + {{- title .Title -}} {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}} {{- end -}} @@ -8,7 +8,7 @@
{{- /* Title */ -}} -

{{- .Title -}}

+

{{- title .Title -}}

{{- /* Subtitle */ -}} {{- with $params.subtitle -}}

{{ . }}

{{- end -}} diff --git a/layouts/_default/single.md b/layouts/_default/single.md index 7a2d138b..f5b6cf19 100644 --- a/layouts/_default/single.md +++ b/layouts/_default/single.md @@ -1,9 +1,9 @@ {{- $params := partial "function/params.html" -}} {{- $author := .Store.Get "author" -}} -# {{ .Title }} +# {{ title .Title }} {{ if $params.password -}} - ***{{ T "single.encryptedAbstract" }}*** + _**{{ T "single.encryptedAbstract" }}**_ {{- else -}} {{ .RawContent | replaceRE "\n?{{% fixit-encryptor .+ %}}((\n|.)*){{% /fixit-encryptor %}}\n?" "" }} {{- end }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index f86b3c93..3392b79b 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -31,7 +31,7 @@ {{- $icon | partial "plugin/icon.html" -}} {{- end -}} {{- end -}} - {{ .Title }} + {{ title .Title }} {{- /* Meta */ -}} diff --git a/layouts/index.archives.html b/layouts/index.archives.html index b5fe3e9b..a3c9fe85 100644 --- a/layouts/index.archives.html +++ b/layouts/index.archives.html @@ -51,7 +51,7 @@ {{- if eq $repost.enable true -}} {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}} {{- end -}} - {{- .LinkTitle -}} + {{- title .LinkTitle -}} {{- .Date | dateFormat ($.Site.Params.archives.dateFormat | default "01-02") -}} diff --git a/layouts/page/friends.html b/layouts/page/friends.html index f3f2947d..b1c81af3 100644 --- a/layouts/page/friends.html +++ b/layouts/page/friends.html @@ -1,5 +1,5 @@ {{- define "title" -}} - {{- .Title -}} + {{- title .Title -}} {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}} {{- end -}} @@ -8,7 +8,7 @@
{{- /* Title */ -}} -

{{- .Title -}}

+

{{- title .Title -}}

{{- /* Subtitle */ -}} {{- with $params.subtitle -}}

{{ . }}

{{- end -}}
diff --git a/layouts/partials/breadcrumb.html b/layouts/partials/breadcrumb.html index 1ead5c0c..9788217b 100644 --- a/layouts/partials/breadcrumb.html +++ b/layouts/partials/breadcrumb.html @@ -3,10 +3,10 @@ {{- end -}} diff --git a/layouts/partials/plugin/share.html b/layouts/partials/plugin/share.html index 74a76a63..fa13e023 100644 --- a/layouts/partials/plugin/share.html +++ b/layouts/partials/plugin/share.html @@ -1,9 +1,10 @@ {{- $share := (partial "function/params.html").share | default dict -}} {{- if $share.enable -}} + {{- $title := title .Title -}} {{- /* 001: Twitter */ -}} {{- if $share.Twitter -}} - + {{- dict "Class" "fa-brands fa-twitter fa-fw" | partial "plugin/icon.html" -}} {{ end -}} @@ -24,14 +25,14 @@ {{- /* 004: WhatsApp */ -}} {{- if $share.Whatsapp -}} - + {{- dict "Class" "fa-brands fa-whatsapp fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 005: Viber */ -}} {{- if $share.Viber -}} - + {{- dict "Class" "fa-brands fa-viber fa-fw" | partial "plugin/icon.html" -}} {{ end -}} @@ -45,14 +46,14 @@ {{- /* 007: Tumblr */ -}} {{- if $share.Tumblr -}} - + {{- dict "Class" "fa-brands fa-tumblr fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 008: Hacker News */ -}} {{- if $share.Hackernews -}} - + {{- dict "Class" "fa-brands fa-hacker-news fa-fw" | partial "plugin/icon.html" -}} {{ end -}} @@ -66,35 +67,35 @@ {{- /* 010: VK */ -}} {{- if $share.VK -}} - + {{- dict "Class" "fa-brands fa-vk fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 011: Buffer */ -}} {{- if $share.Buffer -}} - + {{- dict "Class" "fa-brands fa-buffer fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 012: Xing */ -}} {{- if $share.Xing -}} - + {{- dict "Class" "fa-brands fa-xing fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 013: Line */ -}} {{- if $share.Line -}} - + {{- dict "Simpleicons" "line" "Prefix" (.Scratch.Get "cdn" | default dict).simpleIconsPrefix | partial "plugin/icon.html" -}} {{ end -}} {{- /* 014: Instapaper */ -}} {{- if $share.Instapaper -}} - + {{- dict "Simpleicons" "instapaper" "Prefix" (.Scratch.Get "cdn" | default dict).simpleIconsPrefix | partial "plugin/icon.html" -}} {{ end -}} @@ -114,14 +115,14 @@ {{- /* 018: Flipboard */ -}} {{- if $share.Flipboard -}} - + {{- dict "Class" "fa-brands fa-flipboard fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 019: 微博 */ -}} {{- if $share.Weibo -}} - + {{- dict "Class" "fa-brands fa-weibo fa-fw" | partial "plugin/icon.html" -}} {{ end -}} @@ -131,56 +132,56 @@ {{- /* 021: Myspace */ -}} {{- if $share.Myspace -}} - + {{- dict "Simpleicons" "myspace" "Prefix" (.Scratch.Get "cdn" | default dict).simpleIconsPrefix | partial "plugin/icon.html" -}} {{ end -}} {{- /* 022: Blogger */ -}} {{- if $share.Blogger -}} - + {{- dict "Class" "fa-brands fa-blogger fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 023: 百度 */ -}} {{- if $share.Baidu -}} - + {{- dict "Simpleicons" "baidu" "Prefix" (.Scratch.Get "cdn" | default dict).simpleIconsPrefix | partial "plugin/icon.html" -}} {{ end -}} {{- /* 024: OK.RU */ -}} {{- if $share.Odnoklassniki -}} - + {{- dict "Class" "fa-brands fa-odnoklassniki fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 025: Evernote */ -}} {{- if $share.Evernote -}} - + {{- dict "Class" "fa-brands fa-evernote fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 026: Skype */ -}} {{- if $share.Skype -}} - + {{- dict "Class" "fa-brands fa-skype fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 027: Trello */ -}} {{- if $share.Trello -}} - + {{- dict "Class" "fa-brands fa-trello fa-fw" | partial "plugin/icon.html" -}} {{ end -}} {{- /* 028: Mix */ -}} {{- if $share.Mix -}} - + {{- dict "Class" "fa-brands fa-mix fa-fw" | partial "plugin/icon.html" -}} {{ end -}} diff --git a/layouts/partials/recently-updated.html b/layouts/partials/recently-updated.html index 56de0c8d..7cd16d61 100644 --- a/layouts/partials/recently-updated.html +++ b/layouts/partials/recently-updated.html @@ -22,7 +22,7 @@ {{- if eq $repost.enable true -}} {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}} {{- end -}} - {{- .LinkTitle -}} + {{- title .LinkTitle -}} {{- with .Lastmod | dateFormat (.Site.Params.section.dateformat | default "01-02") -}} diff --git a/layouts/partials/single/collection-list.html b/layouts/partials/single/collection-list.html index b10a6baa..37490dfb 100644 --- a/layouts/partials/single/collection-list.html +++ b/layouts/partials/single/collection-list.html @@ -19,17 +19,18 @@
{{- end -}} diff --git a/layouts/taxonomy/terms/collections.html b/layouts/taxonomy/terms/collections.html index 4f555dda..ba7764e1 100644 --- a/layouts/taxonomy/terms/collections.html +++ b/layouts/taxonomy/terms/collections.html @@ -20,7 +20,7 @@ {{- if eq $repost.enable true -}} {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}} {{- end -}} - {{- .LinkTitle -}} + {{- title .LinkTitle -}}
{{- end -}}