Skip to content

Commit 2d83ceb

Browse files
committed
chore: fix rss to show all content and sections
1 parent 54aeebf commit 2d83ceb

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ home = ["HTML", "RSS", "Offline"]
2222
[outputFormats]
2323
[outputFormats.RSS]
2424
mediaType = "application/rss+xml"
25-
baseName = "feed"
25+
baseName = "rss"
2626

2727
[languages]
2828
[languages.fa]

layouts/_default/rss.xml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,34 @@
1313
{{ with .OutputFormats.Get "RSS" }}
1414
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
1515
{{ end }}
16-
{{ range .Pages }}
16+
17+
{{/* Collect pages: for home use all regular pages (nested), else keep current context */}}
18+
{{ $pages := .Pages }}
19+
{{ if .IsHome }}
20+
{{ $pages = .Site.RegularPages }}
21+
{{ end }}
22+
23+
{{/* Optional: include section index pages (_index.md) too: uncomment next line */}}
24+
{{/* $pages = union $pages .Site.Sections */}}
25+
26+
{{/* Sort by date (newest first) */}}
27+
{{ $pages = sort $pages "Date" "desc" }}
28+
29+
{{/* Apply rssLimit from config if set (>0) */}}
30+
{{ $limit := .Site.Config.Services.RSS.Limit }}
31+
{{ if gt $limit 0 }}
32+
{{ $pages = first $limit $pages }}
33+
{{ end }}
34+
35+
{{ range $pages }}
1736
<item>
18-
<author>{{.Site.Params.Author.name}}</author>
37+
<author>{{ .Site.Params.Author.name }}</author>
1938
<title>{{ .Title }}</title>
2039
<link>{{ .Permalink }}</link>
2140
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
2241
{{ with .Site.Params.Author.email }}<author>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</author>{{end}}
2342
<guid>{{ .Permalink }}</guid>
24-
<description>{{ .Content | html }}</description>
43+
<description>{{ with .Summary }}{{ . | html }}{{ else }}{{ .Content | html }}{{ end }}</description>
2544
</item>
2645
{{ end }}
2746
</channel>

0 commit comments

Comments
 (0)