From ab91d9b59025ddc5e05d02dd1f21ba879f011720 Mon Sep 17 00:00:00 2001 From: iGor milhit Date: Mon, 1 Jun 2020 15:56:45 +0200 Subject: [PATCH] RSS: Improves the RSS template Reuses the latest Hugo embedded RSS template and adapts it with full content and publish date. Fixes #9, thus restoring a RSS feed different for the entire site, the section, taxonomy terms, and so on. Co-Authored-by: Igor Milhit --- CHANGELOG.md | 7 +++++-- layouts/_default/rss.xml | 20 ++++++++++++++++---- layouts/partials/head.html | 5 ++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c745b..dd5c78a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,15 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -## [Unreleased](https://framagit.org/iGormilhit/portfoliGor/compare/0.1.0...HEAD) +## [Unreleased](https://framagit.org/iGormilhit/portfoliGor/compare/0.1.1...HEAD) + +## [0.1.1](https://framagit.org/iGormilhit/portfoliGor/compare/0.1.0...0.1.1) - 2020-06-01 ### Fixed +- RSS: Improves the RSS template [`#9`](https://framagit.org/iGormilhit/portfoliGor/issues/9) - layout: improve list of post taxonomy terms [`#10`](https://framagit.org/iGormilhit/portfoliGor/issues/10) ### Commits -- documentation: add a changelog and auto-changelog [`891ee57`](https://framagit.org/iGormilhit/portfoliGor/commit/891ee575858f4c02795171ffeaeb7640de9ead92) +- documentation: add a changelog and auto-changelog [`31b27df`](https://framagit.org/iGormilhit/portfoliGor/commit/31b27df95ffcab2b5857fa63346e6a8a6998b5d1) - lists: sort list by reverse publication date [`920fe4d`](https://framagit.org/iGormilhit/portfoliGor/commit/920fe4d1566b9755b2551854a6042beec8f8905a) ## 0.1.0 - 2020-05-22 diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 0f4f1fd..854c203 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,4 +1,16 @@ -{{ printf "" | safeHTML }} +{{- $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 }} @@ -11,13 +23,13 @@ {{.}}{{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 }} + {{ printf "" .Permalink .MediaType | safeHTML }} {{ end }} - {{ range .Site.RegularPages }} + {{ range $pages }} {{ .Title }} {{ .Permalink }} - {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ .PublishDate.Format "2006-01-02" | safeHTML }} {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} {{ .Permalink }} {{ .Content | html }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index c26af0f..364182f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -13,8 +13,7 @@ {{ $styles := resources.Get "scss/main.scss" | toCSS $options | minify }} {{ end }} - - {{ with .OutputFormats.Get "RSS" }} + {{ range .AlternativeOutputFormats -}} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} - {{ end }} +{{ end -}}