blob: eabd8994a64e82b3880b00b78682d7ccab787197 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
|
{{- $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 -}}
{{- safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }}
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="{{ site.LanguageCode }}" xml:base="{{ site.BaseURL }}">
{{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "title.html" .) | safeHTML }}
{{ with site.Params.description }}{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}{{ end }}
{{- $output_formats := .OutputFormats }}
{{- range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{- with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .RelPermalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
{{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }}{{ $logo = $logo.Resize "96x96" }}<icon>{{ $logo.Permalink | absURL }}</icon>
<logo>{{ $logo.Permalink | absURL }}</logo>{{ with site.Author.name }}
<author>
{{ printf `<name type="html"><![CDATA[%s]]></name>` . | safeHTML }}
{{ with site.Author.email }}<email>{{ . | html }}</email>{{ end }}
</author>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "©" "©" }}
<rights>{{ $copyright | plainify }}</rights>{{ end }}
<generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if not site.LastChange.IsZero }}
<updated>{{ site.LastChange.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}{{ $uuid := sha1 (site.BaseURL | absURL) }}
<id>urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}</id>{{- range $pages }}
<entry>
{{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL) }}{{ $page := . }}
{{ $section := .Section }}
<category term="{{ $section }}" />
{{ range (.GetTerms "tags") }}
{{ if not (eq .LinkTitle $section) }}
<category term="{{ .LinkTitle }}" x="y" />
{{ end }}
{{ end }}
<link rel="alternate" type="type/html" href="{{ $url }}?utm_source=atom_feed" />
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
{{/* See: https://discourse.gohugo.io/t/using-regularpages-related-gives-me-keywords-index-support-error/35657?u=egrep */}}
{{ $related := first 5 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
{{ range $related }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
{{ end }}
<published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>{{ if ne .Date .Lastmod }}
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}
<id>urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}</id>
{{ if .Params.author }}
{{- $author_type := (printf "%T" .Params.author) }}
{{- if eq $author_type "string" }}
<author>
<name>{{ .Params.author }}</name>
</author>
{{- else if eq $author_type "[]string" }}
{{ range .Params.author }}
<author>
<name>{{ .Name }}</name>
</author>
{{ end }}
{{- end }}
{{ end }}
{{ printf `<summary type="html"><![CDATA[%s]]></summary>` .Summary | safeHTML }}
</entry>{{ end }}
</feed>
|