config: add author deprecation warning #693

This commit is contained in:
Sören Weber 2023-10-20 20:08:37 +02:00
parent 841f9a6b46
commit c893eb5147
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 19 additions and 25 deletions

View file

@ -11,15 +11,7 @@
{{- end }} {{- end }}
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} {{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
{{- $authorName := "" }} {{- $authorName := partialCached "authorname.hugo" . }}
{{- 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 }}
{{- $pages := .Page.Pages }} {{- $pages := .Page.Pages }}
{{- $limit := .Site.Config.Services.RSS.Limit }} {{- $limit := .Site.Config.Services.RSS.Limit }}

View file

@ -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 }}

View file

@ -14,22 +14,7 @@
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex"> <meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }} {{- end }}
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}"> <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
{{- $authorName := "" }} {{- $authorName := partialCached "authorname.hugo" . }}
{{- 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 }}
<meta name="author" content="{{ $authorName }}"> <meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }} {{- partial "twitter_cards.html" . }}
{{- partial "opengraph.html" . }} {{- partial "opengraph.html" . }}