diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 25b0d148..b64752bb 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,4 +1,5 @@ -{{/* Generate RSS with full page content rather than just summary. */}} +{{- /* Generate RSS v2 with full page content. */ -}} +{{- /* Upstream Hugo bug - RSS dates can be in future: https://github.com/gohugoio/hugo/issues/3918 */ -}} {{- $pages := .Data.Pages -}} {{- $limit := site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} @@ -7,24 +8,28 @@ {{- printf "" | safeHTML }} - {{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ site.Title }}{{ end }} + {{ if ne .Title site.Title }}{{ with .Title }}{{.}} | {{ end }}{{end}}{{ site.Title }} {{ .Permalink }} - Recent content {{ if ne .Title site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ site.Title }} - Source Themes Academic (https://sourcethemes.com/academic/){{ 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 }} - {{replace . "{year}" now.Year | plainify}}{{end}}{{ if not .Date.IsZero }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{ with .OutputFormats.Get "RSS" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{ end }} + {{- with .OutputFormats.Get "RSS" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{ end -}} + {{ .Title | default site.Title }} + Source Themes Academic (https://sourcethemes.com/academic/) + {{- with site.LanguageCode }}{{.}}{{end -}} + {{- with site.Copyright }}{{ replace (replace . "{year}" now.Year) "©" "©" | plainify }}{{end -}} + {{- if not .Date.IsZero }}{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end -}} + {{- if .Scratch.Get "og_image" }} + + {{ .Scratch.Get "og_image" }} + {{ .Title | default site.Title }} + {{ .Permalink }} + + {{end -}} {{ range $pages }} {{ .Title }} {{ .Permalink }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with site.Author.email }}{{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}} {{ .Permalink }} {{ .Content | html }} diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html index 375ce0cb..c6e170ac 100644 --- a/layouts/partials/site_head.html +++ b/layouts/partials/site_head.html @@ -16,7 +16,7 @@ {{ $superuser_username = path.Base (path.Split .Path).Dir }} {{ $superuser_role = .Params.role }} {{ end }} - {{ $scr.Set "superuser_username" $superuser_username }}{{/* For access from page_author.html. */}} + {{ $scr.Set "superuser_username" $superuser_username }}{{/* Set superuser globally for page_author.html. */}} {{ with $superuser_name }}{{ end }} @@ -156,6 +156,9 @@ {{ $og_image = printf "img/%s" .Params.header.image | absURL }} {{ else if site.Params.sharing_image }} {{ $og_image = printf "img/%s" site.Params.sharing_image | absURL }} + {{ else if site.Params.logo }} + {{ $og_image = (printf "img/%s" site.Params.logo) | absURL }} + {{ $twitter_card = "summary" }} {{ else if site.Params.avatar }} {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }} {{ $twitter_card = "summary" }} @@ -163,6 +166,7 @@ {{ $og_image = "img/icon-192.png" | absURL }} {{ $twitter_card = "summary" }} {{ end }} + {{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}} {{ with site.Params.twitter }} @@ -178,11 +182,14 @@ {{- end -}} {{ if .IsPage }} - {{ if not .PublishDate.IsZero }} - {{ else if not .Date.IsZero }}{{ end }} - {{ if not .Lastmod.IsZero }}{{ end }} + {{ if not .PublishDate.IsZero }} + + {{ else if not .Date.IsZero }} + + {{ end }} + {{ if not .Lastmod.IsZero }}{{ end }} {{ else }} - {{ if not .Date.IsZero }}{{ end }} + {{ if not .Date.IsZero }}{{ end }} {{ end }} {{ partial "cookie_consent" . }}