Skip to content

Commit c69541e

Browse files
committed
rss: adjust to Hugo's build-in code #824
1 parent b262c0b commit c69541e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

layouts/_default/rss.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
1717
{{- $authorName := partialCached "authorname.hugo" . }}
1818

19-
{{- $pages := .Page.Pages }}
19+
{{- $pages := .Pages }}
2020
{{- $limit := .Site.Config.Services.RSS.Limit }}
21-
{{- if ge $limit 0 }}
21+
{{- if ge $limit 1 }}
2222
{{- $pages = $pages | first $limit }}
2323
{{- end }}
24+
2425
{{- $page := . }}
2526
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
2627
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@@ -33,7 +34,7 @@
3334
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
3435
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
3536
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
36-
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
37+
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
3738
{{- with .OutputFormats.Get "rss" }}
3839
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
3940
{{- end -}}
@@ -43,10 +44,10 @@
4344
<item>
4445
<title>{{ .Title }}</title>
4546
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
46-
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
47+
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
4748
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
4849
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid>
49-
<description>{{ .Summary | html }}</description>
50+
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
5051
</item>
5152
{{- end }}
5253
{{- end }}

0 commit comments

Comments
 (0)