From 9829156c6d9353176f626f93e8a2742f45e14b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 20 Oct 2023 20:15:52 +0200 Subject: [PATCH] config: warings only for Hugo >= 0.120.0 #693 --- layouts/_default/rss.xml | 5 ++++- layouts/partials/authorname.hugo | 27 +++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 0abed62547..50868237cf 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -6,7 +6,10 @@ {{- else }} {{- with .Site.Author.email }} {{- $authorEmail = . }} - {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- $hugoVersion := "0.120.0" }} + {{- if ge hugo.Version $hugoVersion }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} {{- end }} {{- end }} diff --git a/layouts/partials/authorname.hugo b/layouts/partials/authorname.hugo index 1fcd62e276..c5252e2bf9 100644 --- a/layouts/partials/authorname.hugo +++ b/layouts/partials/authorname.hugo @@ -1,17 +1,20 @@ {{- $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 }} + {{- 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 }} + {{- with .Site.Author.name }} + {{- $authorName = . }} + {{- $hugoVersion := "0.120.0" }} + {{- if ge hugo.Version $hugoVersion }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} + {{- end }} {{- end }} {{- return $authorName }} \ No newline at end of file