aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-10-04 19:48:03 -0400
committertdro <tdro@noreply.example.com>2022-10-04 19:48:03 -0400
commitd07cf2691794e2d371ca5ea529428b5f58fac024 (patch)
treed7ed43b6b00f51135ef2a83cd2b40722fcb04907
parentfc175fbf07469ccef2260436ddde717e1e9fc1ba (diff)
downloadcanory-d07cf2691794e2d371ca5ea529428b5f58fac024.tar.gz
canory-d07cf2691794e2d371ca5ea529428b5f58fac024.tar.bz2
canory-d07cf2691794e2d371ca5ea529428b5f58fac024.zip
themes/default/layouts/_default/rss: Move logic outside
-rw-r--r--themes/default/layouts/_default/rss.xml36
1 files changed, 25 insertions, 11 deletions
diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml
index 0364b25..6548c76 100644
--- a/themes/default/layouts/_default/rss.xml
+++ b/themes/default/layouts/_default/rss.xml
@@ -1,9 +1,26 @@
{{- $pageContext := . -}}
-{{- if .IsHome -}}{{ $pageContext = .Site }}{{- end -}}
+
+{{- if .IsHome -}}
+ {{- $pageContext = .Site -}}
+{{- end -}}
+
{{- $pages := $pageContext.RegularPages -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
+
{{- if ge $limit 1 -}}
-{{- $pages = $pages | first $limit -}}
+ {{- $pages = $pages | first $limit -}}
+{{- end -}}
+
+{{- $lastBuildDate := now.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
+
+{{- if not .Date.IsZero -}}
+ {{- $lastBuildDate = .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
+{{- end -}}
+
+{{- $atomLink := "" -}}
+
+{{- with .OutputFormats.Get "RSS" -}}
+ {{- $atomLink = printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML -}}
{{- end -}}
{{- $author := partial "function-authors-data.html" . -}}
@@ -29,21 +46,18 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
- <title>{{ partial "base-title" . }}</title>
+ <title>{{ partial "base-title.html" . }}</title>
<link>{{ .Permalink }}</link>
- <description>Recent from {{ partial "base-title" . }}</description>
+ <description>Recent from {{ partial "base-title.html" . }}</description>
<language>{{ .Site.LanguageCode }}</language>
- <category>{{ partial "author-user" . }}</category>
+ <category>{{ partial "author-user.html" . }}</category>
<image>
- <title>{{ partial "base-title" . }}</title>
+ <title>{{ partial "base-title.html" . }}</title>
<url>{{ $image.Permalink }}</url>
<link>{{ .Permalink }}</link>
</image>
- {{ if not .Date.IsZero -}}
- <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
- {{ with .OutputFormats.Get "RSS" }}
- {{- printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML -}}
- {{ end }}
+ <lastBuildDate>{{ $lastBuildDate }}</lastBuildDate>
+ {{ $atomLink }}
{{- range $pages }}
{{ if and (not .Params.Unlisted) (not .ExpiryDate) }}
<item>