Skip to content

Commit a881f03

Browse files
Merge pull request #165 from pine64/full_rss
Add full RSS version
2 parents 60b2e60 + b2fc8fe commit a881f03

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

  • themes/pinetheme/layouts/_default
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{{- $authorEmail := "" }}
2+
{{- with site.Params.author }}
3+
{{- if reflect.IsMap . }}
4+
{{- with .email }}
5+
{{- $authorEmail = . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- end }}
9+
10+
{{- $authorName := "" }}
11+
{{- with site.Params.author }}
12+
{{- if reflect.IsMap . }}
13+
{{- with .name }}
14+
{{- $authorName = . }}
15+
{{- end }}
16+
{{- else }}
17+
{{- $authorName = . }}
18+
{{- end }}
19+
{{- end }}
20+
21+
{{- $pctx := . }}
22+
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
23+
{{- $pages := slice }}
24+
{{- if or $.IsHome $.IsSection }}
25+
{{- $pages = $pctx.RegularPages }}
26+
{{- else }}
27+
{{- $pages = $pctx.Pages }}
28+
{{- end }}
29+
{{- $limit := .Site.Config.Services.RSS.Limit }}
30+
{{- if ge $limit 1 }}
31+
{{- $pages = $pages | first $limit }}
32+
{{- end }}
33+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
34+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
35+
<channel>
36+
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
37+
<link>{{ .Permalink }}</link>
38+
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
39+
<generator>Hugo</generator>
40+
<language>{{ site.Language.Locale }}</language>{{ with $authorEmail }}
41+
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
42+
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
43+
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
44+
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
45+
{{- with .OutputFormats.Get "RSS" }}
46+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
47+
{{- end }}
48+
{{- range $pages }}
49+
<item>
50+
<title>{{ .Title }}</title>
51+
<link>{{ .Permalink }}</link>
52+
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
53+
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
54+
<guid>{{ .Permalink }}</guid>
55+
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
56+
</item>
57+
{{- end }}
58+
</channel>
59+
</rss>

0 commit comments

Comments
 (0)