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