From c69541e983fbf5a3a49d3c48d986f948f7bb9a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 7 Apr 2024 23:16:37 +0200 Subject: [PATCH] rss: adjust to Hugo's build-in code #824 --- layouts/_default/rss.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 4319aa1ae2..8ee0401515 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -16,11 +16,12 @@ {{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} {{- $authorName := partialCached "authorname.hugo" . }} -{{- $pages := .Page.Pages }} +{{- $pages := .Pages }} {{- $limit := .Site.Config.Services.RSS.Limit }} -{{- if ge $limit 0 }} +{{- if ge $limit 1 }} {{- $pages = $pages | first $limit }} {{- end }} + {{- $page := . }} {{- printf "" | safeHTML }} @@ -33,7 +34,7 @@ {{ . }}{{ 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 }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} {{- with .OutputFormats.Get "rss" }} {{ printf "" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }} {{- end -}} @@ -43,10 +44,10 @@ {{ .Title }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} - {{ .Summary | html }} + {{ .Summary | transform.XMLEscape | safeHTML }} {{- end }} {{- end }}