Skip to content

Commit

Permalink
Implemented upstream changes to feed templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Apr 23, 2024
1 parent fa8675b commit b1ecbbe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
19 changes: 12 additions & 7 deletions layouts/_default/list.json.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := $pctx.RegularPages -}}
{{- $limit := site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{ $length := (len $pages) -}}
{
"version": "https://jsonfeed.org/version/1.1",
Expand Down
61 changes: 33 additions & 28 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := $pctx.RegularPages -}}
{{- $limit := site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ site.Title }}{{ end }}</title>
<title>{{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>{{ i18n "string_recent_content" }} {{ if ne .Title site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>
{{ with site.LanguageCode -}}
<description>{{ i18n "string_recent_content" }} {{ if ne .Title site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ site.Title }}</description>
<generator>Hugo</generator>
{{- with site.LanguageCode }}
<language>{{ . }}</language>
{{ end -}}
{{ with site.Params.author.email -}}
{{- end }}
{{- with site.Params.author.email }}
<managingEditor>{{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }}</managingEditor>
{{ end -}}
{{ with site.Params.author.email -}}
{{- end }}
{{- with site.Params.author.email }}
<webMaster>{{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }}</webMaster>
{{ end -}}
{{ with site.Copyright -}}
{{- end }}
{{- with site.Copyright }}
<copyright>{{ . }}</copyright>
{{ end -}}
{{ if not .Date.IsZero -}}
{{- end }}
{{- if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end -}}
{{ with .OutputFormats.Get "RSS" -}}
{{- end }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end -}}
{{ range $pages -}}
{{- end }}
{{- range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with site.Params.author.email -}}
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with site.Params.author.email }}
<author>{{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }}</author>
{{ end -}}
{{- end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
</item>
{{ end -}}
{{- end }}
</channel>
</rss>

0 comments on commit b1ecbbe

Please sign in to comment.