rss.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {{- $pctx := . -}}
  2. {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
  3. {{- $pages := slice -}}
  4. {{- if or $.IsHome $.IsSection -}}
  5. {{- $pages = $pctx.RegularPages -}}
  6. {{- else -}}
  7. {{- $pages = $pctx.Pages -}}
  8. {{- end -}}
  9. {{- $pages := where $pages "Params.hidden" "!=" true -}}
  10. {{- $limit := .Site.Config.Services.RSS.Limit -}}
  11. {{- if ge $limit 1 -}}
  12. {{- $pages = $pages | first $limit -}}
  13. {{- end -}}
  14. {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
  15. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  16. <channel>
  17. <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
  18. <link>{{ .Permalink }}</link>
  19. <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
  20. <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
  21. <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
  22. <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
  23. <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
  24. <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
  25. <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
  26. {{- with .OutputFormats.Get "RSS" -}}
  27. {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
  28. {{- end -}}
  29. {{ range $pages }}
  30. {{- $content := safeHTML (.Summary | html) -}}
  31. {{- if .Site.Params.rssFullContent -}}
  32. {{- $content = safeHTML (.Content | html) -}}
  33. {{- end -}}
  34. <item>
  35. <title>{{ .Title }}</title>
  36. <link>{{ .Permalink }}</link>
  37. <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
  38. {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
  39. <guid>{{ .Permalink }}</guid>
  40. <description>
  41. {{- $image := partial "helper/image" (dict "Context" . "Type" "rss") -}}
  42. {{- if $image.exists -}}
  43. {{ "<" | html }}img src="{{ $image.permalink | absURL }}" alt="Featured image of post {{ .Title }}" {{ "/>" | html}}
  44. {{- end -}}{{ $content }}</description>
  45. </item>
  46. {{ end }}
  47. </channel>
  48. </rss>