Skip to content

Commit 76a3d1c

Browse files
Override site.Author deprecated
1 parent a3635a0 commit 76a3d1c

1 file changed

Lines changed: 124 additions & 0 deletions

File tree

layouts/_default/list.atom.xml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
2+
<feed xmlns="http://www.w3.org/2005/Atom"{{ with site.LanguageCode }} xml:lang="{{ . }}"{{ end }}>
3+
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
4+
{{- $title := site.Title -}}
5+
{{- with .Title -}}
6+
{{- if (not (eq . site.Title)) -}}
7+
{{- $title = printf `%s %s %s` . (i18n "feed_title_on" | default "on") site.Title -}}
8+
{{- end -}}
9+
{{- end -}}
10+
{{- if .IsTranslated -}}
11+
{{ $title = printf "%s (%s)" $title (index site.Data.i18n.languages .Lang) }}
12+
{{- end -}}
13+
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
14+
{{ with (or (.Param "subtitle") (.Param "tagline")) }}
15+
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
16+
{{ end }}
17+
{{ $output_formats := .OutputFormats }}
18+
{{ range $output_formats -}}
19+
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
20+
{{ with $output_formats.Get .Name }}
21+
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
22+
{{- end -}}
23+
{{- end }}
24+
{{- range .Translations }}
25+
{{ $output_formats := .OutputFormats }}
26+
{{- $lang := .Lang }}
27+
{{- $langstr := index site.Data.i18n.languages .Lang }}
28+
{{ range $output_formats -}}
29+
{{ with $output_formats.Get .Name }}
30+
{{ printf `<link href=%q rel="alternate" type=%q hreflang=%q title="[%s] %s" />` .Permalink .MediaType.Type $lang $langstr .Name | safeHTML }}
31+
{{- end -}}
32+
{{- end }}
33+
{{- end }}
34+
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
35+
{{ with site.Copyright }}
36+
{{- $copyright := replace . "{year}" now.Year -}} {{/* In case the site.copyright uses a special string "{year}" */}}
37+
{{- $copyright = replace $copyright "&copy;" "©" -}}
38+
<rights>{{ $copyright | plainify }}</rights>
39+
{{- end }}
40+
{{ with .Param "feed" }}
41+
{{/* For this to work, the $icon file should be present in the assets/ directory */}}
42+
{{- $icon := .icon | default "icon.svg" -}}
43+
{{- with resources.Get $icon -}}
44+
<icon>{{ (. | fingerprint).Permalink }}</icon>
45+
{{- end }}
46+
47+
{{/* For this to work, the $logo file should be present in the assets/ directory */}}
48+
{{- $logo := .logo | default "logo.svg" -}}
49+
{{- with resources.Get $logo -}}
50+
<logo>{{ (. | fingerprint).Permalink }}</logo>
51+
{{- end }}
52+
{{ end }}
53+
{{ with site.Params.author }}
54+
{{ with .name -}}
55+
<author>
56+
<name>{{ . }}</name>
57+
{{ with $.Site.Params.author.email }}
58+
<email>{{ . }}</email>
59+
{{ end -}}
60+
</author>
61+
{{- end }}
62+
{{ end }}
63+
{{ with site.Params.id }}
64+
<id>{{ . | plainify }}</id>
65+
{{ else }}
66+
<id>{{ .Permalink }}</id>
67+
{{ end }}
68+
{{- $limit := (cond (le site.Config.Services.RSS.Limit 0) 65536 site.Config.Services.RSS.Limit) }}
69+
{{- $feed_sections := site.Params.feedSections | default site.Params.mainSections -}}
70+
{{/* Range through only the pages with a Type in $feed_sections. */}}
71+
{{- $pages := where .RegularPages "Type" "in" $feed_sections -}}
72+
{{- if (eq .Kind "home") -}}
73+
{{- $pages = where site.RegularPages "Type" "in" $feed_sections -}}
74+
{{- end -}}
75+
{{/* Remove the pages that have the disable_feed parameter set to true. */}}
76+
{{- $pages = where $pages ".Params.disable_feed" "!=" true -}}
77+
{{/* Remove the pages that have the unlisted parameter set to true. */}}
78+
{{- $pages = where $pages ".Params.unlisted" "!=" true -}}
79+
{{- range first $limit $pages }}
80+
{{ $page := . }}
81+
<entry>
82+
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
83+
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" />
84+
{{- range .Translations }}
85+
{{- $link := printf "%s?utm_source=atom_feed" .Permalink | safeHTML }}
86+
{{- printf `<link href=%q rel="alternate" type="text/html" hreflang=%q />` $link .Lang | safeHTML }}
87+
{{- end }}
88+
{{/* rel=related: See https://validator.w3.org/feed/docs/atom.html#link */}}
89+
{{- range first 5 (site.RegularPages.Related .) }}
90+
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
91+
{{- end }}
92+
{{ with .Params.id }}
93+
<id>{{ . | plainify }}</id>
94+
{{ else }}
95+
<id>{{ .Permalink }}</id>
96+
{{ end }}
97+
{{ with .Params.authors -}}
98+
{{- range . -}}
99+
<author>
100+
<name>{{ . }}</name>
101+
</author>
102+
{{- end -}}
103+
{{- end }}
104+
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
105+
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
106+
{{ $description1 := .Description | default "" }}
107+
{{ $description := (cond (eq "" $description1) "" (printf "<blockquote>%s</blockquote>" ($description1 | markdownify))) }}
108+
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
109+
{{ with site.Taxonomies }}
110+
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
111+
{{ with $page.Param $taxo }}
112+
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
113+
{{ with site.GetPage (printf "/%s" $taxo) }}
114+
{{ $taxonomy_page := . }}
115+
{{ range $taxo_list }} <!-- Below, assuming pretty URLs -->
116+
<category scheme="taxonomy:{{ printf "%s" $taxo | humanize }}" term="{{ (. | urlize) }}" label="{{ . }}" />
117+
{{ end }}
118+
{{ end }}
119+
{{ end }}
120+
{{ end }}
121+
{{ end }}
122+
</entry>
123+
{{ end }}
124+
</feed>

0 commit comments

Comments
 (0)