From cf5d8755ac8f52eaa56b26e830b4783360a20f3b Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 2 Nov 2022 09:14:47 -0700 Subject: [PATCH] Add photo thumbnail, category, series, and tags to RSS items --- layouts/_default/rss.rss | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/layouts/_default/rss.rss b/layouts/_default/rss.rss index 38d7088..5c3a806 100644 --- a/layouts/_default/rss.rss +++ b/layouts/_default/rss.rss @@ -1,19 +1,21 @@ {{- $pctx := . -}} -{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- if .IsHome -}} + {{ $pctx = .Site }} +{{- end -}} {{- $pages := slice -}} {{- if or $.IsHome $.IsSection -}} -{{- $pages = $pctx.RegularPages -}} + {{- $pages = $pctx.RegularPages -}} {{- else -}} -{{- $pages = $pctx.Pages -}} + {{- $pages = $pctx.Pages -}} {{- end -}} {{- $limit := .Site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} -{{- $pages = $pages | first $limit -}} + {{- $pages = $pages | first $limit -}} {{- end -}} {{- printf "" | safeHTML }} - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} {{ .Permalink }} Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} Hugo -- gohugo.io{{ with .Site.LanguageCode }} @@ -23,19 +25,32 @@ {{.}}{{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 }} + {{ printf "" .Permalink .MediaType | safeHTML }} {{- end -}} {{ range $pages }} - {{ if ne .Params.rss_ignore true }} - - {{ .Title }} - {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .Permalink }} - {{ .Content | html }} - - {{ end }} + {{ if ne .Type "page" }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + + {{ if eq .Section "photos" }} + {{ $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) }} + + {{ end }} + {{ .Content | html }} + + {{ with index (.GetTerms "series") 0 }}{{ .Title }}{{ end }} + {{ range .GetTerms "categories" }} + {{ .Title }} + {{ end }} + {{ range .GetTerms "tags" }} + {{ .Title }} + {{ end }} + + {{ end }} {{ end }}