Skip to content

Commit

Permalink
rss: adjust to Hugo's build-in code #824
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Apr 7, 2024
1 parent b262c0b commit c69541e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
Expand All @@ -33,7 +34,7 @@
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "rss" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
{{- end -}}
Expand All @@ -43,10 +44,10 @@
<item>
<title>{{ .Title }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid>
<description>{{ .Summary | html }}</description>
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
{{- end }}
Expand Down

0 comments on commit c69541e

Please sign in to comment.