Skip to content

Commit 17cc8df

Browse files
committed
feat: use new rss config to show full content
1 parent bfaaec3 commit 17cc8df

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

layouts/_default/rss.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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">
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+
<generator>Hugo -- gohugo.io</generator>
20+
<language>{{ site.LanguageCode }}</language>{{ with .Site.Params.Author.email }}
21+
<managingEditor>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Params.Author.email }}
22+
<webMaster>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</webMaster>{{end}}
23+
{{ if .Site.Params.footer.showCopyright | default true -}}
24+
<copyright>{{ with replace .Site.Params.copyright "{ year }" now.Year }}{{.}}{{ else }}© {{ now.Format "2006" }} {{ .Site.Params.Author.name }}{{- end }}</copyright>
25+
{{- end }}
26+
{{ if not .Date.IsZero }}<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
27+
{{- with .OutputFormats.Get "RSS" -}}
28+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
29+
{{- end -}}
30+
{{ if and (.Site.Params.rssnext.feedId) (.Site.Params.rssnext.userId) }}
31+
<follow_challenge>
32+
<feedId>{{ .Site.Params.rssnext.feedId }}</feedId>
33+
<userId>{{ .Site.Params.rssnext.userId }}</userId>
34+
</follow_challenge>
35+
{{ end }}
36+
{{ range $pages }}
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.Params.Author.email }}<author>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</author>{{end}}
42+
<guid>{{ .Permalink }}</guid>
43+
<description>{{ .Content | html }}</description>
44+
{{ range ( where .Site.RegularPages ".RelPermalink" .RelPermalink | first 1 ) }}
45+
{{- $images := .Resources.ByType "image" -}}
46+
{{- $featured := $images.GetMatch "*feature*" -}}
47+
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
48+
{{- with $featured -}}
49+
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="{{ $featured.Permalink }}" />
50+
{{- end -}}
51+
{{ end }}
52+
</item>
53+
{{ end }}
54+
</channel>
55+
</rss>

0 commit comments

Comments
 (0)