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 <igor@milhit.ch>
pull/32/head 0.1.1
iGor milhit 2020-06-01 15:56:45 +02:00
parent 31b27df95f
commit ab91d9b590
Signed by: igor
GPG Key ID: 692D97C3D0228A99
3 changed files with 23 additions and 9 deletions

View File

@ -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). 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 ### 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) - layout: improve list of post taxonomy terms [`#10`](https://framagit.org/iGormilhit/portfoliGor/issues/10)
### Commits ### 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) - lists: sort list by reverse publication date [`920fe4d`](https://framagit.org/iGormilhit/portfoliGor/commit/920fe4d1566b9755b2551854a6042beec8f8905a)
## 0.1.0 - 2020-05-22 ## 0.1.0 - 2020-05-22

View File

@ -1,4 +1,16 @@
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | 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 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
@ -11,13 +23,13 @@
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }} {{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }} {{ end }}
{{ range .Site.RegularPages }} {{ range $pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <pubDate>{{ .PublishDate.Format "2006-01-02" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid> <guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description> <description>{{ .Content | html }}</description>

View File

@ -13,8 +13,7 @@
{{ $styles := resources.Get "scss/main.scss" | toCSS $options | minify }} {{ $styles := resources.Get "scss/main.scss" | toCSS $options | minify }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen"> <link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">
{{ end }} {{ end }}
<!-- <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}style.css"> --> {{ range .AlternativeOutputFormats -}}
{{ with .OutputFormats.Get "RSS" }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end }} {{ end -}}
</head> </head>