35 lines (35 loc) · 1.49 KB
 1{{- $pages := .RegularPages -}}
 2{{- if .IsHome }}{{ $pages = site.RegularPages }}{{ end -}}
 3{{- $pages = where $pages "Draft" false -}}
 4{{- $pages = where $pages "Date" "<=" now -}}
 5{{- $pages = where $pages "Params.rss" "!=" false -}}
 6{{- $pages = sort $pages "Date" "desc" -}}
 7{{- $pages = first 20 $pages -}}
 8{{- $feed := .OutputFormats.Get "RSS" -}}
 9{{- $description := .Description | default (printf "Latest posts from %s" site.Title) -}}
10{{- printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML -}}
11<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
12  <channel>
13    <title>{{ .Title }} | {{ site.Title }}</title>
14    <link>{{ .Permalink }}</link>
15    {{- with $feed }}
16    <atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
17    {{- end }}
18    <description>{{ $description | plainify }}</description>
19    <copyright>© {{ now.Year }} {{ site.Title }}. Licensed under {{ site.Params.license.name }} ({{ site.Params.license.url }}).</copyright>
20    <language>{{ site.Language.Locale }}</language>
21    <generator>Hugo {{ hugo.Version }}</generator>
22    <ttl>60</ttl>
23    {{- range $pages }}
24    <item>
25      <title>{{ .Title }}</title>
26      <link>{{ .Permalink }}</link>
27      <guid isPermaLink="true">{{ .Permalink }}</guid>
28      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
29      {{- with .Description }}
30      <description>{{ . | transform.XMLEscape | safeHTML }}</description>
31      {{- end }}
32    </item>
33    {{- end }}
34  </channel>
35</rss>