diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 855df30ae9..0abed62547 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -11,15 +11,7 @@ {{- end }} {{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} -{{- $authorName := "" }} -{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.name }} - {{- $authorName = .Site.Params.author.name }} -{{- else }} - {{- with .Site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} -{{- end }} +{{- $authorName := partialCached "authorname.hugo" . }} {{- $pages := .Page.Pages }} {{- $limit := .Site.Config.Services.RSS.Limit }} diff --git a/layouts/partials/authorname.hugo b/layouts/partials/authorname.hugo new file mode 100644 index 0000000000..1fcd62e276 --- /dev/null +++ b/layouts/partials/authorname.hugo @@ -0,0 +1,17 @@ +{{- $authorName := "" }} +{{- if .Site.Params.author }} + {{- if reflect.IsMap .Site.Params.author }} + {{- with .Site.Params.author.name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- warnf "%q: DEPRECATED usage of 'params.author' config parameter found, replace it with `params.author.name` in your config.toml; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5230" .File.Path }} + {{- $authorName = .Site.Params.author }} + {{- end }} +{{- else }} + {{- with .Site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} +{{- return $authorName }} \ No newline at end of file diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index d9ae09921c..1c49d99fdc 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -14,22 +14,7 @@ {{- end }} - {{- $authorName := "" }} - {{- if .Site.Params.author }} - {{- if reflect.IsMap .Site.Params.author }} - {{- with .Site.Params.author.name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- warnf "According to Hugo 0.120.0 the author key in params configuration should now be a map and contain of name and email fields." }} - {{- $authorName = .Site.Params.author }} - {{- end }} - {{- else }} - {{- with .Site.Author.name }} - {{- $authorName = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} - {{- end }} - {{- end }} + {{- $authorName := partialCached "authorname.hugo" . }} {{- partial "twitter_cards.html" . }} {{- partial "opengraph.html" . }} \ No newline at end of file