aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/layouts/_default/rss.xml
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-07-06 01:19:16 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-07-06 01:19:16 -0400
commitbd51b97e6953d5df4124ada7e29def41b2f7b09b (patch)
treeb65e40a7bca84c810c53efb63172c622444d6ccb /layouts/_default/rss.xml
parent37f4840e9c1e4dd3ac092c4a69535be3e77f0d0e (diff)
add rss to templates
Diffstat (limited to 'layouts/_default/rss.xml')
-rw-r--r--layouts/_default/rss.xml41
1 files changed, 41 insertions, 0 deletions
diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml
new file mode 100644
index 0000000..24e182e
--- /dev/null
+++ b/layouts/_default/rss.xml
@@ -0,0 +1,41 @@
+{{- $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 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title>
+ <link>{{ .Permalink }}</link>
+ <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
+ <generator>Hugo</generator>
+ <language>{{ site.Language.LanguageCode }}</language>
+ <copyright>Copyright {{ now.Format "2006" }}, JP Appel</copyright>
+ {{ if not .Date.IsZero }}
+ <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.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 }}
+ {{- range $pages }}
+ <item>
+ <title>{{ .Title }}</title>
+ <link>{{ .Permalink }}</link>
+ <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
+ {{ with .Params.author }}
+ <author>{{ . }}</author>
+ {{ end }}
+ <guid>{{ .Permalink }}</guid>
+ <description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
+ </item>
+ {{- end }}
+ </channel>
+</rss>