rss.xml

 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>{{ .Site.Title }}</title>
17    <link>{{ .Permalink }}</link>
18    <description>Recent content {{ if ne  .Title  .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>{{ with .Site.LanguageCode }}
19    <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
20    <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
21    <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
22    <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
23    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
24    {{- with .OutputFormats.Get "RSS" -}}
25    {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
26    {{- end -}}
27    {{ range $pages }}
28    <item>
29      <title>{{ .Title }}</title>
30      <link>{{ .Permalink }}</link>
31      {{- if .Params.Tags }}
32      <category>{{ range $key, $value := .Params.Tags }}{{ if $key }}/{{ end }}{{ $value }}{{ end }}</category>>
33      {{- else }}
34      {{- if .Params.Rss_only }}
35      <category>RSSOnly</category>>
36      {{- end }}
37      {{- end }}
38      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
39      {{- with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
40      <guid>{{ .Permalink }}</guid>
41      <description>{{ .Content | html }}</description>
42    </item>
43    {{ end }}
44  </channel>
45</rss>