rss.xml (2382B)
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 }} 23 {{ $pctx = .Site }} 24 {{ end }} 25 26 {{- $pages := slice }} 27 {{- if or $.IsHome $.IsSection }} 28 {{- $pages = $pctx.RegularPages }} 29 {{- else }} 30 {{- $pages = $pctx.Pages }} 31 {{- end }} 32 33 {{- $limit := .Site.Config.Services.RSS.Limit }} 34 {{- if ge $limit 1 }} 35 {{- $pages = $pages | first $limit }} 36 {{- end }} 37 38 {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} 39 40 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 41 <channel> 42 <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} @ {{ end }}{{ .Site.Title }}{{ end }}</title> 43 <link>{{ .Permalink }}</link> 44 <description>{{ T "recent" }} {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}@ {{ .Site.Title }}</description> 45 <generator>Hugo</generator> 46 <language>{{ site.Language.Locale }}</language>{{ with $authorEmail }} 47 <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} 48 <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} 49 <copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }} 50 <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} 51 {{- with .OutputFormats.Get "RSS" }} 52 {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} 53 {{- end }} 54 {{- range $pages }} 55 <item> 56 <title>{{ .Title }}</title> 57 <link>{{ .Permalink }}</link> 58 <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> 59 {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} 60 <guid>{{ .Permalink }}</guid> 61 <description>{{ .Summary | transform.XMLEscape | safeHTML }}</description> 62 </item> 63 {{- end }} 64 </channel> 65 </rss>