From dfa94d3f3e320ee7dd32658cb1b96224a118fe8c Mon Sep 17 00:00:00 2001 From: PCloud Date: Tue, 24 Sep 2024 12:18:08 +0100 Subject: [PATCH 1/2] fix: move .Site.Author to .Site.Params.Author --- assets/css/main.css | 218 +++++++++--------- exampleSite/config/_default/author.toml | 8 - exampleSite/config/_default/params.toml | 7 + .../theme-documentation-basics/index.en.md | 17 +- .../theme-documentation-basics/index.zh-cn.md | 15 +- layouts/index.feed | 6 +- layouts/index.rss.xml | 6 +- layouts/partials/footer.html | 2 +- layouts/partials/head/seo.html | 12 +- layouts/partials/meta/author.html | 8 +- layouts/partials/rss/item.html | 2 +- layouts/partials/single/sponsor.html | 4 +- layouts/posts/rss.xml | 6 +- layouts/taxonomy/rss.xml | 6 +- 14 files changed, 157 insertions(+), 160 deletions(-) delete mode 100644 exampleSite/config/_default/author.toml diff --git a/assets/css/main.css b/assets/css/main.css index 67acf1091..4e38972c7 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -1,5 +1,113 @@ +*, ::before, ::after { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + +::backdrop { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + /* -! tailwindcss v3.4.11 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.12 | MIT License | https://tailwindcss.com */ /* @@ -669,114 +777,6 @@ html.dark { --showcase-hover-color: white; } -*, ::before, ::after { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; - --tw-contain-size: ; - --tw-contain-layout: ; - --tw-contain-paint: ; - --tw-contain-style: ; -} - -::backdrop { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; - --tw-contain-size: ; - --tw-contain-layout: ; - --tw-contain-paint: ; - --tw-contain-style: ; -} - .tw-m-0 { margin: 0px; } diff --git a/exampleSite/config/_default/author.toml b/exampleSite/config/_default/author.toml deleted file mode 100644 index 1350d2f91..000000000 --- a/exampleSite/config/_default/author.toml +++ /dev/null @@ -1,8 +0,0 @@ -# Author config -# 作者配置 - -name = "PCloud" -email = "heige.pcloud@outlook.com" -link = "https://github.com/HEIGE-PCloud" -avatar = "/images/avatar.webp" -gravatarEmail = "heige.pcloud@outlook.com" diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index c9b710ae2..13ad417c1 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -28,6 +28,13 @@ license = '}} App icon config # {{< version 0.2.14 >}} License information license = 'CC BY-NC 4.0' + # Author config + [params.author] + name = "xxxx" + email = "" + link = "" + avatar = "" + gravatarEmail = "" + # {{< version 0.2.0 >}} App icon config [params.app] # optional site title override for the app when added to an iOS home screen or Android launcher title = "DoIt" @@ -868,14 +875,6 @@ Please open the code block below to view the complete sample configuration {{< f startLevel = 2 endLevel = 6 -# Author config -[author] - name = "xxxx" - email = "" - link = "" - avatar = "" - gravatarEmail = "" - # Sitemap config [sitemap] changefreq = "weekly" diff --git a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md index 23904c054..f9eb30082 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md @@ -227,6 +227,13 @@ optimizeImages = true srcsetLargeResizeMethod = "2000x webp Lanczos q75" # {{< version 0.2.14 >}} 版权信息 license = 'CC BY-NC 4.0' + # 作者配置 + [params.author] + name = "xxxx" + email = "" + link = "" + avatar = "" + gravatarEmail = "" # {{< version 0.2.0 >}} 应用图标配置 [params.app] # 当添加到 iOS 主屏幕或者 Android 启动器时的标题, 覆盖默认标题 @@ -870,14 +877,6 @@ optimizeImages = true startLevel = 2 endLevel = 6 -# 作者配置 -[author] - name = "xxxx" - email = "" - link = "" - avatar = "" - gravatarEmail = "" - # 网站地图配置 [sitemap] changefreq = "weekly" diff --git a/layouts/index.feed b/layouts/index.feed index 69ad75d06..689c8f89c 100644 --- a/layouts/index.feed +++ b/layouts/index.feed @@ -10,10 +10,10 @@ {{ end -}} "icon" : "{{ `/apple-touch-icon.png` | absURL }}", "favicon" : "{{ `/favicon.ico` | absURL }}", - {{ with .Site.Author.name -}} + {{ with .Site.Params.Author.name -}} "author" : { - "name" : "{{ . }}"{{ with $.Site.Author.link }}, - "url": "{{ . }}"{{ end }}{{ with $.Site.Author.avatar }}, + "name" : "{{ . }}"{{ with $.Site.Params.Author.link }}, + "url": "{{ . }}"{{ end }}{{ with $.Site.Params.Author.avatar }}, "avatar": "{{ . | absURL }}"{{ end }} }, {{ end -}} diff --git a/layouts/index.rss.xml b/layouts/index.rss.xml index 4bc04b165..bbe3959ab 100644 --- a/layouts/index.rss.xml +++ b/layouts/index.rss.xml @@ -15,12 +15,12 @@ {{- . -}} {{- end -}} - {{- with .Site.Author.email -}} + {{- with .Site.Params.Author.email -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} {{- end -}} {{- with .Site.Copyright -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6d161785b..1fe4cf1f8 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -43,7 +43,7 @@ {{- /* Author */ -}} {{- if ne .Site.Params.footer.author false -}} -  {{ .Site.Author.name }} +  {{ .Site.Params.Author.name }} {{- end -}} {{- /* License */ -}} diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index b00f5de99..28744b800 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -92,7 +92,7 @@ {{- with .Site.Copyright -}} "license": {{ . | safeHTML }}, {{- end -}} - {{- $publisher := .Params.author | default .Site.Author.name | default (T "author") | dict "name" -}} + {{- $publisher := .Params.author | default .Site.Params.Author.name | default (T "author") | dict "name" -}} {{- $publisher = $params.seo.publisher | default dict | merge $publisher -}} "publisher": { "@type": "Organization", @@ -137,8 +137,8 @@ {{- end -}} ], {{- else -}} - {{- $link := .Params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}} - {{- with .Params.author | default .Site.Author.name | default (T "author") -}} + {{- $link := .Params.authorlink | default .Site.Params.Author.link | default .Site.Home.RelPermalink -}} + {{- with .Params.author | default .Site.Params.Author.name | default (T "author") -}} "author": { "@type": "Person", "name": {{ . | safeHTML }}, @@ -171,7 +171,7 @@ {{- with .Site.LanguageCode -}} "inLanguage": "{{ . }}", {{- end -}} - {{- with .Site.Author.name -}} + {{- with .Site.Params.Author.name -}} "author": { "@type": "Person", "name": {{ . | safeHTML }} @@ -216,10 +216,10 @@ "@type": "Person", "name": {{ .Site.Params.footer.author | safeHTML }} }, - {{- else if .Site.Author.name -}} + {{- else if .Site.Params.Author.name -}} "copyrightHolder": { "@type": "Person", - "name": {{ .Site.Author.name | safeHTML }} + "name": {{ .Site.Params.Author.name | safeHTML }} }, {{- end -}} "name": {{ .Site.Title | safeHTML }} diff --git a/layouts/partials/meta/author.html b/layouts/partials/meta/author.html index 2ab19ee2a..188a0fae7 100644 --- a/layouts/partials/meta/author.html +++ b/layouts/partials/meta/author.html @@ -29,13 +29,13 @@ {{- end -}} {{- else -}} - {{- $author := .Params.author | default .Site.Author.name | default (T "author") -}} - {{- $link := .Params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}} + {{- $author := .Params.author | default .Site.Params.Author.name | default (T "author") -}} + {{- $link := .Params.authorlink | default .Site.Params.Author.link | default .Site.Home.RelPermalink -}} {{- $gravatar := 0 -}} - {{- with .Site.Author.gravataremail -}} + {{- with .Site.Params.Author.gravataremail -}} {{- $gravatar = md5 . | printf "https://www.gravatar.com/avatar/%v?s=240&d=mp" -}} {{- end -}} - {{- $avatar := .Params.authoravatar | default .Site.Author.avatar | default $gravatar | default false -}} + {{- $avatar := .Params.authoravatar | default .Site.Params.Author.avatar | default $gravatar | default false -}} {{- $options := dict "Class" "author" "Destination" $link "Title" "Author" "Rel" "author" "Content" $author -}} {{- if $avatar -}} {{- dict "Width" "16" "Height" "16" "Src" $avatar "Alt" (printf "%v avatar" $author) "OptimConfig" $optim "Class" "tw-inline-block tw-max-h-4 tw-rounded-full tw-translate-y-[-2px] tw-mr-1" | partial "plugin/image.html" -}} diff --git a/layouts/partials/rss/item.html b/layouts/partials/rss/item.html index c1c6b86fe..4859c8b9a 100644 --- a/layouts/partials/rss/item.html +++ b/layouts/partials/rss/item.html @@ -1,4 +1,4 @@ -{{- $params := .Page.Params | merge .Site.Params.Page | merge (dict "author" .Site.Author.name) -}} +{{- $params := .Page.Params | merge .Site.Params.Page | merge (dict "author" .Site.Params.Author.name) -}} {{- $image := $params.featuredImagePreview | default $params.featuredImage -}} {{- with .Page.Resources.GetMatch (printf "%s" ($image)) -}} {{- $image = .RelPermalink -}} diff --git a/layouts/partials/single/sponsor.html b/layouts/partials/single/sponsor.html index f1e49c72a..dbc72b17a 100644 --- a/layouts/partials/single/sponsor.html +++ b/layouts/partials/single/sponsor.html @@ -1,6 +1,6 @@ {{- $enable := .Params.sponsor.enable | default .Site.Params.sponsor.enable -}} -{{- $avatar := .Site.Author.avatar -}} -{{- with .Site.Author.gravataremail -}} +{{- $avatar := .Site.Params.Author.avatar -}} +{{- with .Site.Params.Author.gravataremail -}} {{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%v?s=240&d=mp" -}} {{- end -}} {{- $bio := .Params.sponsor.bio | default .Site.Params.sponsor.bio -}} diff --git a/layouts/posts/rss.xml b/layouts/posts/rss.xml index faef41056..6402f0418 100644 --- a/layouts/posts/rss.xml +++ b/layouts/posts/rss.xml @@ -15,12 +15,12 @@ {{- . -}} {{- end -}} - {{- with .Site.Author.email -}} + {{- with .Site.Params.Author.email -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} {{- end -}} {{- with .Site.Copyright -}} diff --git a/layouts/taxonomy/rss.xml b/layouts/taxonomy/rss.xml index a597e5692..da5d63ba1 100644 --- a/layouts/taxonomy/rss.xml +++ b/layouts/taxonomy/rss.xml @@ -15,12 +15,12 @@ {{- . -}} {{- end -}} - {{- with .Site.Author.email -}} + {{- with .Site.Params.Author.email -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} - {{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}} + {{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}} {{- end -}} {{- with .Site.Copyright -}} From 48042d58d75405adf11ee93f948499650b4e6621 Mon Sep 17 00:00:00 2001 From: PCloud Date: Tue, 24 Sep 2024 12:26:09 +0100 Subject: [PATCH 2/2] chore: add deprecation check --- layouts/partials/init.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/layouts/partials/init.html b/layouts/partials/init.html index ca519c4f5..a8633b034 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -45,6 +45,10 @@ {{- warnf "Run `npx pagefind --site $YOUR_PUBLIC_DIR` after site build to create pagefind index" -}} {{- end -}} +{{- if .Site.Author -}} + {{- errorf ".Site.Author is deprecated, use .Site.Params.Author instead. See https://github.com/gohugoio/hugo/issues/12228" -}} +{{- end -}} + {{- .Scratch.Set "params" $params -}} {{- .Scratch.Set "this" dict -}}