mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
config: add author deprecation warning #693
This commit is contained in:
parent
841f9a6b46
commit
c893eb5147
3 changed files with 19 additions and 25 deletions
|
@ -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 }}
|
||||||
|
|
17
layouts/partials/authorname.hugo
Normal file
17
layouts/partials/authorname.hugo
Normal 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 }}
|
|
@ -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" . }}
|
Loading…
Reference in a new issue