diff --git a/exampleSite/config/_default/config.toml b/exampleSite/config/_default/config.toml index fb68cc15bc..eb973455b5 100644 --- a/exampleSite/config/_default/config.toml +++ b/exampleSite/config/_default/config.toml @@ -212,7 +212,6 @@ title = "Hugo Relearn Theme" images = ["images/hero.png"] editURL = "https://github.com/McShelby/hugo-theme-relearn/edit/main/exampleSite/content/" description = "Documentation for Hugo Relearn Theme" - author = "Sören Weber" showVisitedLinks = true collapsibleMenu = true disableBreadcrumb = false @@ -233,6 +232,8 @@ title = "Hugo Relearn Theme" # security reasons mermaidInitialize = "{ \"securityLevel\": \"loose\" }" mermaidZoom = true + [params.author] + name = "Sören Weber" [params.siteparam.test] text = "A **nested** parameter with formatting" [params.imageEffects] diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 47a9cdb4f9..855df30ae9 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,23 +1,45 @@ {{- partialCached "page-meta.hugo" . .RelPermalink }} +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }} + {{- $authorEmail = .Site.Params.author.email }} +{{- else }} + {{- with .Site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- 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 }} + {{- $pages := .Page.Pages }} -{{- $limit := .Site.Config.Services.RSS.Limit -}} -{{- if ge $limit 0 -}} - {{- $pages = $pages | first $limit -}} +{{- $limit := .Site.Config.Services.RSS.Limit }} +{{- if ge $limit 0 }} + {{- $pages = $pages | first $limit }} {{- end }} {{- $page := . }} {{- printf "" | safeHTML }} - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} - {{.}}{{end}}{{ if not .Date.IsZero }} + {{ . }}{{end}}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} + {{ . }}{{ end }}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" -}} + {{- with .OutputFormats.Get "RSS" }} {{ printf "" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }} {{- end -}} {{- range $pages }} @@ -27,9 +49,7 @@ {{ .Title }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{- with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}} - {{- end }} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} {{ .Summary | html }} diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 74e50d6522..d9ae09921c 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -14,8 +14,22 @@ {{- end }} - {{- with .Site.Params.author }} - + {{- $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 }} + {{- partial "twitter_cards.html" . }} {{- partial "opengraph.html" . }} \ No newline at end of file diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 47be47c567..046119d150 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -107,7 +107,19 @@ {{- end }} {{- end }} {{- end }} + +{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}} +{{- $facebookAdmin := "" }} +{{- with site.Params.social.facebook_admin }} + {{- $facebookAdmin = . }} +{{- else }} + {{- with site.Social.facebook_admin }} + {{- $facebookAdmin = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }} + {{- end }} +{{- end }} + {{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with .Site.Social.facebook_admin }} +{{- with $facebookAdmin }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html index 2d3266ce33..9a69d25ad5 100644 --- a/layouts/partials/twitter_cards.html +++ b/layouts/partials/twitter_cards.html @@ -43,6 +43,18 @@ {{- end }} -{{- with .Site.Social.twitter }} + +{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} +{{- $twitterSite := "" }} +{{- with site.Params.social.twitter }} + {{- $twitterSite = . }} +{{- else }} + {{- with site.Social.twitter }} + {{- $twitterSite = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }} + {{- end }} +{{- end }} + +{{- with $twitterSite }} {{- end }} \ No newline at end of file