Skip to content

Commit

Permalink
Update feed generation to the proper page set and support the limit s…
Browse files Browse the repository at this point in the history
…etting
  • Loading branch information
spookey committed Nov 25, 2019
1 parent 288dedb commit 495e2fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to
fingerprint them as well).
- Enable placement of favicon into ``assets`` folder to enable fingerprinting
as well.
- Updated feed template to honor the ``services.rss.limit`` setting.

### Changed
- Updated ``rollup``, ``autoprefixer``, fonts and inner dependencies.
Expand All @@ -31,6 +32,7 @@ and this project adheres to
- Prevent adding the ``pure-table`` CSS class to tables containing
code listings. This fixes broken display of code, and allows better output
of line numbers alongside code samples.
- Generate feed from the proper input source to find all matching pages.


## [v0.2.2]
Expand Down
6 changes: 6 additions & 0 deletions _sites/changelog/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ author:
# email: mail@example.org


services:
rss:
# limit the length of the rss feed (default: unlimited)
limit: 0


menu:

footer:
Expand Down
5 changes: 5 additions & 0 deletions _sites/example/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ paginatePath = "page"
email = "mail@example.org"


[services.rss]
# limit the length of the rss feed (default: unlimited)
limit = 0


[menu]

# Configure main menu entries (header)
Expand Down
9 changes: 8 additions & 1 deletion layouts/_default/rss.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := $pctx.RegularPages -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
<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>
Expand All @@ -20,7 +27,7 @@
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end }}
{{- range .Data.Pages }}
{{- range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
Expand Down

0 comments on commit 495e2fd

Please sign in to comment.