Migrate deprecated author as a site custom parameter
Some checks are pending
Build demo / build (push) Waiting to run

This commit is contained in:
Gabriel Arazas 2024-11-19 11:33:08 +08:00
parent 91eb61eb18
commit 664e5c3928
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
5 changed files with 20 additions and 15 deletions

View File

@ -19,6 +19,12 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
== Unreleased == 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.

View File

@ -168,11 +168,11 @@ paginate = 20
path = "github.com/foo-dogsquared/hugo-web-feeds" path = "github.com/foo-dogsquared/hugo-web-feeds"
[author.john_doe] [params.author.john_doe]
name = "John Doe" name = "John Doe"
email = "johndoe@example.com" email = "johndoe@example.com"
[author.jane_doe] [params.author.jane_doe]
name = "Jane Doe" name = "Jane Doe"
email = "jane_doe_1995@example.com" 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 === Authors
Despite this theme is aimed for personal blogs, it has support for multiple 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. The author object only requires a value for `name` key.
You can also add more keys for more metadata. You can also add more keys for more metadata.
.An example of indicating authors in the site configuration .An example of indicating authors in the site configuration
[source, toml] [source, toml]
---- ----
[author.john_doe] [params.author.john_doe]
name = "John Doe" name = "John Doe"
email = "john_doe@example.com" email = "john_doe@example.com"
birthdate = "1996-01-12" birthdate = "1996-01-12"
[author.jane_doe] [params.author.jane_doe]
name = "Jane Doe" name = "Jane Doe"
---- ----

View File

@ -29,13 +29,6 @@ rssLimit = 2
experimental = true experimental = true
[author]
[author.john_doe]
name = "John Doe"
email = "johndoe@example.com"
[languages] [languages]
[languages.en] [languages.en]
# This key is used for more readable links. # This key is used for more readable links.
@ -133,3 +126,9 @@ rssLimit = 2
[params] [params]
toc = true toc = true
[params.author]
[params.author.john_doe]
name = "John Doe"
email = "johndoe@example.com"

View File

@ -3,7 +3,7 @@
<a href="#top">{{ i18n "back_to_top" | default "Back to top" }}</a> <a href="#top">{{ i18n "back_to_top" | default "Back to top" }}</a>
<!-- Linking to other languages' homepage. --> <!-- Linking to other languages' homepage. -->
{{ if hugo.IsMultiLingual }} {{ if hugo.IsMultilingual }}
<p>{{ i18n "multilingual" }}: <p>{{ i18n "multilingual" }}:
<span class="site__list site__languages"> <span class="site__list site__languages">
{{ range $.Site.Languages }} {{ range $.Site.Languages }}
@ -36,6 +36,6 @@
{{ $markdownOpt := dict "markup" "markdown" }} {{ $markdownOpt := dict "markup" "markdown" }}
<!-- Copyright info. --> <!-- Copyright info. -->
<p>{{ with $.Site.Copyright }}{{ . | $.Site.RenderPage $markdownOpt }}{{ else }}© {{ now.Year }} {{ with $.Site.Author.name }}{{ . }}{{ else }}{{ $.Site.Title }}{{ end }}{{ end }}</p> <p>{{ with $.Site.Copyright }}{{ . | $.Site.RenderPage $markdownOpt }}{{ else }}© {{ now.Year }} {{ with $.Site.Params.author.name }}{{ . }}{{ else }}{{ $.Site.Title }}{{ end }}{{ end }}</p>
</footer> </footer>

View File

@ -34,7 +34,7 @@ It's a very small script so there's little effect on perceived performance. */ -
{{ hugo.Generator }} {{ hugo.Generator }}
<meta charset="utf-8"> <meta charset="utf-8">
{{- with .Site.Author }} {{- with .Site.Params.author }}
{{- $names := slice }} {{- $names := slice }}
{{- range . }}{{ $names = $names | append .name }}{{ end }} {{- range . }}{{ $names = $names | append .name }}{{ end }}
<meta name="author" content="{{ delimit $names " , " (printf " %s " (i18n " and")) }}" /> <meta name="author" content="{{ delimit $names " , " (printf " %s " (i18n " and")) }}" />