Fall back post author to '.Site.Author.name' when it is not set.

'.Site.Author' is a recognized Hugo site variable, c.f. [1].

It's also already used elsewhere within PaperMod, namely in rss.xml.

By falling back to this variable users' configs can be simplified, being
effectively unnecessary to set the author twice, in .Site.Params.author.

[1]: c.f. https://gohugo.io/variables/site/#site-variables-list
This commit is contained in:
Thiago Perrotta 2022-01-14 17:32:48 -05:00
parent 54a3c60735
commit 4b663ca8e3

View File

@ -1,5 +1,5 @@
{{- if or .Params.author .Site.Params.author }} {{- if or .Params.author .Site.Params.author .Site.Author.name }}
{{- $author := (.Params.author | default .Site.Params.author) }} {{- $author := (.Params.author | default .Site.Params.author | default .Site.Author.name) }}
{{- $author_type := (printf "%T" $author) }} {{- $author_type := (printf "%T" $author) }}
{{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} {{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }}
{{- (delimit $author ", " ) }} {{- (delimit $author ", " ) }}