config: warings only for Hugo >= 0.120.0 #693

This commit is contained in:
Sören Weber 2023-10-20 20:15:52 +02:00
parent c893eb5147
commit 9829156c6d
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 19 additions and 13 deletions

View file

@ -6,7 +6,10 @@
{{- else }} {{- else }}
{{- with .Site.Author.email }} {{- with .Site.Author.email }}
{{- $authorEmail = . }} {{- $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 }}
{{- end }} {{- end }}

View file

@ -1,17 +1,20 @@
{{- $authorName := "" }} {{- $authorName := "" }}
{{- if .Site.Params.author }} {{- if .Site.Params.author }}
{{- if reflect.IsMap .Site.Params.author }} {{- if reflect.IsMap .Site.Params.author }}
{{- with .Site.Params.author.name }} {{- with .Site.Params.author.name }}
{{- $authorName = . }} {{- $authorName = . }}
{{- end }} {{- end }}
{{- else }} {{- 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 }} {{- 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 }} {{- $authorName = .Site.Params.author }}
{{- end }} {{- end }}
{{- else }} {{- else }}
{{- with .Site.Author.name }} {{- with .Site.Author.name }}
{{- $authorName = . }} {{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} {{- $hugoVersion := "0.120.0" }}
{{- end }} {{- if ge hugo.Version $hugoVersion }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- return $authorName }} {{- return $authorName }}