summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2021-12-15 14:45:48 +0100
committerPatrick Spek <p.spek@tyil.nl>2021-12-15 14:45:48 +0100
commit1b3ec9f2844e93992aefdbad33d686b9726175e5 (patch)
treeafade0726c06e76de63d04a303118aaff3d33684
parent0b9cecc73374346945e84f0781dedc638f22d5ff (diff)
downloadblog-1b3ec9f2844e93992aefdbad33d686b9726175e5.tar.gz
blog-1b3ec9f2844e93992aefdbad33d686b9726175e5.tar.bz2
Create custom feed page for blog posts
-rw-r--r--content/_index.md2
-rw-r--r--layouts/posts/list.xml37
2 files changed, 38 insertions, 1 deletions
diff --git a/content/_index.md b/content/_index.md
index ad4808c..5b1d94f 100644
--- a/content/_index.md
+++ b/content/_index.md
@@ -54,7 +54,7 @@ discuss something in private.
## RSS
If you'd like to stay up-to-date with my posts, you can subscribe to the [RSS
-feed](/index.xml).
+feed](/posts/index.xml).
[darenet]: https://darenet.org
[git-gh]: https://github.com/tyil
diff --git a/layouts/posts/list.xml b/layouts/posts/list.xml
new file mode 100644
index 0000000..7a4157f
--- /dev/null
+++ b/layouts/posts/list.xml
@@ -0,0 +1,37 @@
+{{- $pctx := . -}}
+{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
+{{- $pages := slice -}}
+{{- range .Sections.Reverse -}}
+{{- $pages = (append $pages .RegularPages) }}
+{{- 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 }}{{.}} on {{ 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 -- gohugo.io</generator>{{ with .Site.LanguageCode }}
+ <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
+ <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
+ <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
+ <copyright>{{.}}</copyright>{{end}}{{ 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 -}}
+ {{ range $pages }}
+ <item>
+ <title>{{ .Title }}</title>
+ <link>{{ .Permalink }}</link>
+ <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 }}</guid>
+ <description>{{ .Summary | html }}</description>
+ </item>
+ {{ end }}
+ </channel>
+</rss>