From 664e5c3928537bc9681dae03e74711e5c5a40f59 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 19 Nov 2024 11:33:08 +0800 Subject: [PATCH] Migrate deprecated author as a site custom parameter --- CHANGELOG.adoc | 6 ++++++ README.adoc | 10 +++++----- exampleSite/hugo.toml | 13 ++++++------- layouts/partials/footer.html | 4 ++-- layouts/partials/head.html | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b83bb93..df3f16b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -19,6 +19,12 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version == Unreleased +=== Updated + +* Change all of the deprecated functions and parameters to their recommended replacements. + +** `$.Site.Author` has been deprecated and instead uses the `$.Site.Params.author` instead. + diff --git a/README.adoc b/README.adoc index 774276f..b10c11c 100644 --- a/README.adoc +++ b/README.adoc @@ -168,11 +168,11 @@ paginate = 20 path = "github.com/foo-dogsquared/hugo-web-feeds" -[author.john_doe] +[params.author.john_doe] name = "John Doe" email = "johndoe@example.com" -[author.jane_doe] +[params.author.jane_doe] name = "Jane Doe" email = "jane_doe_1995@example.com" @@ -250,19 +250,19 @@ Here are some of the assumptions made with certain keys from the site configurat === Authors Despite this theme is aimed for personal blogs, it has support for multiple authors. -As hinted from the example configuration, the author site parameter (i.e., `$.Site.Author`) is a map of objects. +As hinted from the example configuration, the author site parameter (i.e., `$.Site.Params.author`) is a map of objects. The author object only requires a value for `name` key. You can also add more keys for more metadata. .An example of indicating authors in the site configuration [source, toml] ---- -[author.john_doe] +[params.author.john_doe] name = "John Doe" email = "john_doe@example.com" birthdate = "1996-01-12" -[author.jane_doe] +[params.author.jane_doe] name = "Jane Doe" ---- diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 335fc11..071c7f5 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -29,13 +29,6 @@ rssLimit = 2 experimental = true - -[author] - [author.john_doe] - name = "John Doe" - email = "johndoe@example.com" - - [languages] [languages.en] # This key is used for more readable links. @@ -133,3 +126,9 @@ rssLimit = 2 [params] toc = true + +[params.author] + [params.author.john_doe] + name = "John Doe" + email = "johndoe@example.com" + diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 981ee92..f3500c7 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -3,7 +3,7 @@ {{ i18n "back_to_top" | default "Back to top" }} -{{ if hugo.IsMultiLingual }} +{{ if hugo.IsMultilingual }}

{{ i18n "multilingual" }}: {{ range $.Site.Languages }} @@ -36,6 +36,6 @@ {{ $markdownOpt := dict "markup" "markdown" }} -

{{ with $.Site.Copyright }}{{ . | $.Site.RenderPage $markdownOpt }}{{ else }}© {{ now.Year }} {{ with $.Site.Author.name }}{{ . }}{{ else }}{{ $.Site.Title }}{{ end }}{{ end }}

+

{{ with $.Site.Copyright }}{{ . | $.Site.RenderPage $markdownOpt }}{{ else }}© {{ now.Year }} {{ with $.Site.Params.author.name }}{{ . }}{{ else }}{{ $.Site.Title }}{{ end }}{{ end }}

diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 00ab217..4ca45e0 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -34,7 +34,7 @@ It's a very small script so there's little effect on perceived performance. */ - {{ hugo.Generator }} -{{- with .Site.Author }} +{{- with .Site.Params.author }} {{- $names := slice }} {{- range . }}{{ $names = $names | append .name }}{{ end }}