{{ $item := . }}
{{ if .IsHome }}
{{ $item = .Site }}
{{ end }}
{{ $pages := slice }}
{{ if or $.IsHome $.IsSection }}
{{ $pages = $item.RegularPages }}
{{ else }}
{{ $pages = $item.Pages }}
{{ end }}
{{ $limit := .Site.Config.Services.RSS.Limit }}
{{ if ge $limit 1 }}
{{ $pages = $pages | first $limit }}
{{ end }}
{{ $pages = where $pages "Params.paige_hide_rss" "ne" true }}
{{ $title := partial "paige-titles.html" . }}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    {{ with .OutputFormats.Get "RSS" }}
    {{ printf `<atom:link href="%s" rel="self" type="%s"/>` .Permalink .MediaType | safeHTML }}
    {{ end }}
    {{ with .Site.Copyright }}
    <copyright>{{ . }}</copyright>
    {{ end }}
    <description>Recent content{{ with $title }} in {{ . }}{{ end }}</description>
    {{ with .Site.LanguageCode }}
    <language>{{ . }}</language>
    {{ end }}
    {{ if and .Date (not .Date.IsZero) }}
    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
    {{ end }}
    <link>{{ .Permalink }}</link>
    {{ with .Site.Author.email }}
    <managingEditor>{{ . }}</managingEditor>
    {{ end }}
    {{ with $title }}
    <title>{{ . }}</title>
    {{ end }}
    {{ with .Site.Author.email }}
    <webMaster>{{ . }}</webMaster>
    {{ end }}
    {{ range $pages }}
    <item>
      {{ with .Site.Author.email }}
      <author>{{ . }}</author>
      {{ end }}
      {{ if .Content }}
      <description>{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}</description>
      {{ else if .Description }}
      <description>{{ .Description | markdownify | html }}</description>
      {{ end }}
      {{ with .Permalink }}
      <guid>{{ . }}</guid>
      <link>{{ . }}</link>
      {{ end }}
      {{ with .Date }}
      <pubDate>{{ .Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
      {{ end }}
      {{ with .Title }}
      <title>{{ . }}</title>
      {{ end }}
    </item>
    {{ end }}
  </channel>
</rss>
