Skip to content

Commit

Permalink
config: add author deprecation warning #693
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Oct 20, 2023
1 parent 841f9a6 commit c893eb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
10 changes: 1 addition & 9 deletions layouts/_default/rss.xml
Expand Up @@ -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 }}
Expand Down
17 changes: 17 additions & 0 deletions 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 }}
17 changes: 1 addition & 16 deletions layouts/partials/meta.html
Expand Up @@ -14,22 +14,7 @@
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }}
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ 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" . }}
<meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }}
{{- partial "opengraph.html" . }}

0 comments on commit c893eb5

Please sign in to comment.