Skip to content

Commit a9dc91b

Browse files
committed
export full content in rss
1 parent c0945ef commit a9dc91b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

layouts/_default/rss.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{- $pctx := . -}}
2+
{{- if .IsHome -}}{{ $pctx = site }}{{- end -}}
3+
{{- $pages := slice -}}
4+
{{- if or $.IsHome $.IsSection -}}
5+
{{- $pages = $pctx.RegularPages -}}
6+
{{- else -}}
7+
{{- $pages = $pctx.Pages -}}
8+
{{- end -}}
9+
{{- $limit := site.Config.Services.RSS.Limit -}}
10+
{{- if ge $limit 1 -}}
11+
{{- $pages = $pages | first $limit -}}
12+
{{- end -}}
13+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
14+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
15+
<channel>
16+
<title>{{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ site.Title }}{{ end }}</title>
17+
<link>{{ .Permalink }}</link>
18+
<description>Recent content {{ if ne .Title site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ site.Title }}</description>
19+
{{- with site.Params.images }}
20+
<image>
21+
<title>{{ site.Title }}</title>
22+
<url>{{ index . 0 | absURL }}</url>
23+
<link>{{ index . 0 | absURL }}</link>
24+
</image>
25+
{{- end }}
26+
<generator>Hugo -- gohugo.io</generator>{{ with site.LanguageCode }}
27+
<language>{{.}}</language>{{end}}{{ with site.Author.email }}
28+
<managingEditor>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with site.Author.email }}
29+
<webMaster>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with site.Copyright }}
30+
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
31+
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
32+
{{- with .OutputFormats.Get "RSS" -}}
33+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
34+
{{- end -}}
35+
{{ range $pages }}
36+
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
37+
<item>
38+
<title>{{ .Title }}</title>
39+
<link>{{ .Permalink }}</link>
40+
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
41+
{{ with site.Author.email }}<author>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</author>{{end}}
42+
<guid>{{ .Permalink }}</guid>
43+
<description>{{ .Content | html }}</description>
44+
{{- if site.Params.ShowFullTextinRSS }}
45+
<content:encoded>{{ (printf "<![CDATA[%s]]>" .Content) | safeHTML }}</content:encoded>
46+
{{- end }}
47+
</item>
48+
{{- end }}
49+
{{ end }}
50+
</channel>
51+
</rss>
52+

0 commit comments

Comments
 (0)