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