index.xml
· 2.8 KiB · XML
Raw
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .email }}
{{- $authorEmail = . }}
{{- end }}
{{- end }}
{{- else }}
{{- with site.Author.email }}
{{- $authorEmail = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
{{- end }}
{{- end }}
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
{{- $authorName := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- with site.Author.name }}
{{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end }}
{{- range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
</channel>
</rss>
1 | {{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} |
2 | {{- $authorEmail := "" }} |
3 | {{- with site.Params.author }} |
4 | {{- if reflect.IsMap . }} |
5 | {{- with .email }} |
6 | {{- $authorEmail = . }} |
7 | {{- end }} |
8 | {{- end }} |
9 | {{- else }} |
10 | {{- with site.Author.email }} |
11 | {{- $authorEmail = . }} |
12 | {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} |
13 | {{- end }} |
14 | {{- end }} |
15 | |
16 | {{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} |
17 | {{- $authorName := "" }} |
18 | {{- with site.Params.author }} |
19 | {{- if reflect.IsMap . }} |
20 | {{- with .name }} |
21 | {{- $authorName = . }} |
22 | {{- end }} |
23 | {{- else }} |
24 | {{- $authorName = . }} |
25 | {{- end }} |
26 | {{- else }} |
27 | {{- with site.Author.name }} |
28 | {{- $authorName = . }} |
29 | {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} |
30 | {{- end }} |
31 | {{- end }} |
32 | |
33 | {{- $pctx := . }} |
34 | {{- if .IsHome }}{{ $pctx = .Site }}{{ end }} |
35 | {{- $pages := slice }} |
36 | {{- if or $.IsHome $.IsSection }} |
37 | {{- $pages = $pctx.RegularPages }} |
38 | {{- else }} |
39 | {{- $pages = $pctx.Pages }} |
40 | {{- end }} |
41 | {{- $limit := .Site.Config.Services.RSS.Limit }} |
42 | {{- if ge $limit 1 }} |
43 | {{- $pages = $pages | first $limit }} |
44 | {{- end }} |
45 | {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} |
46 | <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> |
47 | <channel> |
48 | <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title> |
49 | <link>{{ .Permalink }}</link> |
50 | <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description> |
51 | <generator>Hugo</generator> |
52 | <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }} |
53 | <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} |
54 | <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} |
55 | <copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }} |
56 | <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} |
57 | {{- with .OutputFormats.Get "RSS" }} |
58 | {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} |
59 | {{- end }} |
60 | {{- range $pages }} |
61 | <item> |
62 | <title>{{ .Title }}</title> |
63 | <link>{{ .Permalink }}</link> |
64 | <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> |
65 | {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} |
66 | <guid>{{ .Permalink }}</guid> |
67 | <description>{{ .Content | transform.XMLEscape | safeHTML }}</description> |
68 | </item> |
69 | {{- end }} |
70 | </channel> |
71 | </rss> |
72 |