rss.xml (2489B)
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 = $pctx.RegularPages }} 26 {{- else }} 27 {{- $pages = $pctx.Pages }} 28 {{- end }} 29 {{- $limit := .Site.Config.Services.RSS.Limit }} 30 {{- if ge $limit 1 }} 31 {{- $pages = $pages | first $limit }} 32 {{- end }} 33 {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} 34 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 35 <channel> 36 <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title> 37 <link>{{ .Permalink }}</link> 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.Language.Locale }}</language> 41 {{ with $authorEmail }} 42 <managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor> 43 {{ end }} 44 {{ with $authorEmail }} 45 <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster> 46 {{ end }} 47 {{ with .Site.Copyright }} 48 <copyright>{{ . }}</copyright> 49 {{ end }} 50 {{ if not .Date.IsZero }} 51 <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate> 52 {{ end }} 53 {{- with .OutputFormats.Get "RSS" }} 54 {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} 55 {{- end }} 56 {{- range $pages }} 57 <item> 58 <title>{{ .Title }}</title> 59 <link>{{ .Permalink }}</link> 60 <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> 61 {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} 62 <guid>{{ .Permalink }}</guid> 63 <description> 64 {{ $mailTo := printf "<p><a href=\"mailto:%s?subject=%s\">✍️ Reply by email</a></p>" $authorEmail .Title }} 65 {{ printf "%s%s" .Content $mailTo | transform.XMLEscape | safeHTML }} 66 </description> 67 </item> 68 {{- end }} 69 </channel> 70 </rss>