Skip to content

Commit

Permalink
fix: filter pages before limit
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Oct 8, 2021
1 parent 8112664 commit 7cf1577
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<!-- Reference: https://tools.ietf.org/html/rfc4287 -->
<!-- Reference: https://github.com/kaushalmodi/hugo-atom-feed/blob/master/layouts/_default/list.atom.xml -->
<!-- Reference: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml -->
{{- $pages := .Site.RegularPages -}}
{{- $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ .Site.LanguageCode }}">
<title type="text">{{ .Site.Title }}</title>
Expand All @@ -29,7 +29,7 @@
<rights>{{ . | plainify | htmlUnescape }}</rights>
{{- end }}
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- range (where $pages "Section" "in" .Site.Params.mainSections) }}
{{- range $pages }}
{{ $page := . }}
{{- $author := partial "utils/author.html" $page -}}
<entry>
Expand Down
8 changes: 4 additions & 4 deletions layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{- `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }}
{{ `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }}
<!-- Reference: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml -->
<!-- Reference: https://github.com/kaushalmodi/hugo-atom-feed/blob/master/layouts/_default/list.atom.xml -->
<!-- Reference: https://validator.w3.org/feed/docs/rss2.html -->
<!-- Reference: https://developers.google.com/gdata/docs/1.0/reference -->
<!-- Reference: https://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared -->
<!-- Reference: https://en.wikipedia.org/wiki/RSS -->
{{- $pages := .Site.RegularPages -}}
{{- $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- $pages = $pages | first $limit -}}
{{- end }}
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
Expand All @@ -32,7 +32,7 @@
{{ with .OutputFormats.Get "SectionsRSS" }}
<atom:link rel="self" type="{{ .MediaType }}" href="{{ .Permalink }}" />
{{ end }}
{{ range (where $pages "Section" "in" .Site.Params.mainSections) }}
{{ range $pages }}
{{ $page := . }}
{{- $author := partial "utils/author.html" $page -}}
<item>
Expand Down

0 comments on commit 7cf1577

Please sign in to comment.