From b1ecbbef64ca2b809ee43a9501d8cee81a417623 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Tue, 23 Apr 2024 09:58:54 +0200 Subject: [PATCH] Implemented upstream changes to feed templates. --- layouts/_default/list.json.json | 19 ++++++---- layouts/_default/rss.xml | 61 ++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index 693a2e2..5cd74d8 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -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", diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 4c85593..77c3e5a 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -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 "" | safeHTML }} - {{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ site.Title }}{{ end }} + {{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ site.Title }}{{ end }} {{ .Permalink }} - {{ i18n "string_recent_content" }} {{ if ne .Title site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ site.Title }} - Hugo -- gohugo.io - {{ with site.LanguageCode -}} + {{ i18n "string_recent_content" }} {{ if ne .Title site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ site.Title }} + Hugo + {{- with site.LanguageCode }} {{ . }} - {{ end -}} - {{ with site.Params.author.email -}} + {{- end }} + {{- with site.Params.author.email }} {{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }} - {{ end -}} - {{ with site.Params.author.email -}} + {{- end }} + {{- with site.Params.author.email }} {{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }} - {{ end -}} - {{ with site.Copyright -}} + {{- end }} + {{- with site.Copyright }} {{ . }} - {{ end -}} - {{ if not .Date.IsZero -}} + {{- end }} + {{- if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ end -}} - {{ with .OutputFormats.Get "RSS" -}} + {{- end }} + {{- with .OutputFormats.Get "RSS" }} {{ printf "" .Permalink .MediaType | safeHTML }} - {{ end -}} - {{ range $pages -}} + {{- end }} + {{- range $pages }} {{ .Title }} {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with site.Params.author.email -}} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with site.Params.author.email }} {{ . }}{{ with site.Params.author.name }} ({{ . }}){{ end }} - {{ end -}} + {{- end }} {{ .Permalink }} - {{ .Content | html }} + {{ .Content | transform.XMLEscape | safeHTML }} - {{ end -}} + {{- end }}