summaryrefslogtreecommitdiffstats
path: root/layouts/_default/list.feed.xml
blob: c4be170dfd4ea2783f807dc73271948ba8ea4994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}

{{- $pages := slice -}}
{{- if $.IsHome -}}
    {{- $mainSections := site.Params.mainSections | default (slice "posts") }}
    {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}}
{{- else if $.IsSection -}}
    {{- $pages = $pctx.RegularPages.ByDate.Reverse -}}
{{- else -}}
    {{- $pages = $pctx.Pages -}}
{{- end -}}

{{- $limit := site.Params.feedSize | default 25 -}}
{{- $pages = $pages | first $limit -}}

{{- $siteLastMod := partial "site-last-mod.html" . -}}
{{- $siteAuthor := partial "site-author.html" . -}}

{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:media="http://search.yahoo.com/mrss/"
    xml:lang="{{ site.LanguageCode }}"
    xml:base="{{ site.BaseURL }}">
    <channel>
        <title>{{ partial "title.html" . }}</title>
        <link>{{ .Permalink }}</link>
        <description>{{ partial "description.html" . }}</description>
        <generator>Hugo {{ hugo.Version }}</generator>
        <language>{{ site.Language.LanguageCode }}</language>{{ with site.Params.Copyright -}}
        {{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "&copy;" "©" }}
        <copyright>{{ $copyright | plainify }}</copyright>{{ end }}
        <lastBuildDate>{{ $siteLastMod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
    {{- $output_formats := .OutputFormats }}
    {{- range $output_formats -}}
    {{- $rel := (or (and (eq "feed" (.Name | lower)) "self") "alternate") -}}
    {{- with $output_formats.Get .Name }}
        {{ printf `<atom:link href=%q rel=%q type=%q title=%q />` .RelPermalink $rel .MediaType.Type .Name | safeHTML }}
    {{- end -}}
    {{- end }}
    {{- range $pages }}
        <item>
            <title>{{ .Title }}</title>
            <link>{{ .Permalink | absURL }}?utm_source=rss_feed</link>
            <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
            {{ with $siteAuthor.email }}<author>{{ . }}{{ with $siteAuthor.name }} ({{ . }}){{ end }}</author>{{ end }}
            <category>{{ .Section }}</category>{{ range (.GetTerms "tags") }}
            <category>{{ .LinkTitle }}</category>{{ end }}
            <guid isPermaLink="false">{{ md5 .Permalink }}</guid>
            <description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
        </item>
    {{ end }}
    </channel>
</rss>