Fix main RSS feed

This commit is contained in:
JP Hastings-Spital 2023-09-15 08:42:45 +01:00
parent fbe0aec3ea
commit db22cddc10

View file

@ -1,14 +1,14 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = index .Site.Sections 0 }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- if .IsHome -}}
{{- $pages = where .Site.RegularPages "Type" "not in" (slice "memex" "timeless" "site-infra") -}}
{{- else if $.IsSection -}}
{{- $pages = .RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- $pages = .Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- printf "<?xml-stylesheet href=\"/rss.xsl\" type=\"text/xsl\"?>" | safeHTML }}
@ -26,16 +26,26 @@
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" (.Permalink | absURL) .MediaType | safeHTML }}
{{- end -}}
{{ range $pages }}
{{ range $pages }}{{ $page := . }}
<item>
<title>{{ .Title }}</title>
<title>{{ .Title | default (delimit (slice "An untitled" (.Date.Format "January") (.Type | singularize)) " ") }}</title>
<link>{{ .Permalink | absURL }}</link>
{{ if .Page.Params.Audio }}<enclosure url="{{ .Permalink | absURL }}{{ .Page.Params.Audio }}" length="{{ (os.Stat (path.Join .File.Dir .Page.Params.Audio)).Size }}" type="audio/mpeg" />{{end}}
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink | absURL }}</guid>
<description>{{ .Summary }}</description>
<content:encoded>{{ .Content | html}}</content:encoded>
<description>
{{- with index .Params.Media 0 }}
<img src="{{ path.Join $page.RelPermalink . | absURL }}" />
{{ end -}}
{{- .Summary -}}
</description>
<content:encoded>
{{- range $i, $src := .Params.Media }}
<img src="{{ path.Join $page.RelPermalink $src | absURL }}" />
{{ end -}}
{{- .Content | html -}}
</content:encoded>
</item>
{{ end }}
</channel>