From 3632294706ccab4d2a169edd245c00bcab532226 Mon Sep 17 00:00:00 2001 From: Xin Date: Fri, 22 Sep 2023 23:41:53 +0100 Subject: [PATCH] chore: update list page RSS template (#75) * chore: update RSS feed template * chore: use html instead of safeHTML --- layouts/_default/list.rss.xml | 43 +++++++++++++++++++++++++++++++++ layouts/section/section.rss.xml | 40 ------------------------------ 2 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 layouts/_default/list.rss.xml delete mode 100644 layouts/section/section.rss.xml diff --git a/layouts/_default/list.rss.xml b/layouts/_default/list.rss.xml new file mode 100644 index 0000000..91db54b --- /dev/null +++ b/layouts/_default/list.rss.xml @@ -0,0 +1,43 @@ + + + {{ .Site.Title }} – {{ .Title }} + {{ .Permalink }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo -- gohugo.io{{ with .Site.LanguageCode }} + {{.}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} + {{.}}{{end}}{{ if not .Date.IsZero }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{ with .OutputFormats.Get "RSS" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{ end }} + {{ if not $.Section }} + {{ $sections := .Site.Params.rss.sections | default (slice "blog") }} + {{ .Scratch.Set "rssPages" (first 50 (where $.Site.RegularPages "Type" "in" $sections )) }} + {{ else }} + {{ if $.Parent.IsHome }} + {{ .Scratch.Set "rssPages" (first 50 (where $.Site.RegularPages "Type" $.Section )) }} + {{ else }} + {{ .Scratch.Set "rssPages" (first 50 $.Pages) }} + {{ end }} + {{ end }} + {{ range (.Scratch.Get "rssPages") }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + + {{ $img := (.Resources.ByType "image").GetMatch "*featured*" }} + {{ with $img }} + {{ $img := .Resize "640x" }} + {{ printf "]]>" $img.Permalink $img.Width $img.Height | safeHTML }} + {{ end }} + {{ .Content | html }} + + + {{ end }} + + diff --git a/layouts/section/section.rss.xml b/layouts/section/section.rss.xml deleted file mode 100644 index 2b15322..0000000 --- a/layouts/section/section.rss.xml +++ /dev/null @@ -1,40 +0,0 @@ -{{- $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 }}{{.}} of {{ end }}{{ .Site.Title }}{{ end }} - {{ .Permalink }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} - Hugo -- gohugo.io - {{ site.Language.LanguageCode }}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} - {{.}}{{end}}{{ if not .Date.IsZero }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" -}} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end -}} - {{ range $pages }} - - {{ .Title }} - {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .Permalink }} - {{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}} - {{ (printf "" .Content) | safeHTML }} - - {{ end }} - - \ No newline at end of file