From 8ecbe90cd4118464f124eab6c4d10fb621d693fa Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 16 Feb 2020 17:55:12 -0500 Subject: [PATCH] Added RSS support Signed-off-by: Brandon Rozek --- layouts/blog/rss.xml | 34 ++++++++++++++++++++++++++++++++++ layouts/partials/header.html | 4 ++++ 2 files changed, 38 insertions(+) create mode 100644 layouts/blog/rss.xml diff --git a/layouts/blog/rss.xml b/layouts/blog/rss.xml new file mode 100644 index 0000000..3e17f48 --- /dev/null +++ b/layouts/blog/rss.xml @@ -0,0 +1,34 @@ +{{- $pctx := . -}} +{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- $pages := $pctx.RegularPages -}} +{{- $limit := .Site.Config.Services.RSS.Limit -}} +{{- if ge $limit 1 -}} +{{- $pages = $pages | first $limit -}} +{{- end -}} +{{- printf "" | safeHTML }} + + + {{ 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 }} + {{.}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} + {{.}}{{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 }} + {{ end }} + {{ range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + {{ .Summary | html }} + + {{ end }} + + \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 9c1d7e7..566d9cb 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -6,4 +6,8 @@

{{ .Site.Params.Author }}

+ + {{ range .AlternativeOutputFormats -}} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} + {{ end -}}