From 8afd881ee3dc53bf5ea3378aa485839ae49e933b Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Sun, 31 Oct 2021 21:04:10 +0100 Subject: [PATCH] added logo and article images to rss, added option to exclude page from rss --- README.md | 1 + content/search.md | 1 + layouts/_default/rss.xml | 45 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 layouts/_default/rss.xml diff --git a/README.md b/README.md index 1ff762a..9f61c58 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ Every post can have various parameters in the frontmatter, here are some that yo - `image`: a link to a feature image for the article, shown in the preview as well - `comments`: boolean, if true it enables comments for the current post, if false it disables them (default is true) - `showDate`: boolean, true by default, if false hides the date. Useful for non-article pages where the date isn't important +- `norss`: boolean, if set to true the page will be skipped in the rss feed # Does *Ficurinia* mean anything? diff --git a/content/search.md b/content/search.md index ae3e341..ec905d4 100644 --- a/content/search.md +++ b/content/search.md @@ -4,4 +4,5 @@ layout: search outputs: - "html" - "json" +norss: true --- diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml new file mode 100644 index 0000000..4d97e2c --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,45 @@ +{{- $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 "" | 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 }} + {{ .Site.Params.Logo | default "/img/icon.svg" | absURL }} + {{- with .OutputFormats.Get "RSS" -}} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end -}} + {{ range $pages }} + {{ if not .Norss }} + + {{ .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 }} + {{ if .Image }} + + {{ end }} + + {{ end }} + {{ end }} + +