You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.3 KiB
XML

{{ $page := . }}
{{ $copyright := site.Copyright }}
{{ $description := or $page.Description "Recent content" }}
{{ $guids := dict }}
{{ $html := $page.AlternativeOutputFormats.Get "html" }}
{{ $lastbuilddate := (partial "paige/changed.html" $page).Format "Mon, 02 Jan 2006 15:04:05 MST" }}
{{ $language := site.LanguageCode | default site.Language.Lang }}
{{ $limit := site.Config.Services.RSS.Limit }}
{{ $link := $page.Permalink }}
{{ $managingeditor := $page.Param "paige.feed.rss.managing_editor" }}
{{ $pagetitle := $page.Title | markdownify | plainify }}
{{ $sitetitle := site.Title | markdownify | plainify }}
{{ $subpages := (cond $page.IsHome site $page).RegularPages }}
{{ $title := "" }}
{{ $webmaster := $page.Param "paige.feed.rss.web_master" }}
{{ if and $pagetitle $sitetitle }}
{{ if $page.IsHome }}
{{ $title = $pagetitle | safeHTML }}
{{ else }}
{{ $title = printf "%s · %s" $pagetitle $sitetitle | safeHTML }}
{{ end }}
{{ else if $pagetitle }}
{{ $title = $pagetitle | safeHTML }}
{{ else if $sitetitle }}
{{ $title = $sitetitle | safeHTML }}
{{ end }}
{{ $subpages = where $subpages "Params.paige.feed.hide_page" "ne" true }}
{{ if ge $limit 0 }}
{{ $subpages = $subpages | first $limit }}
{{ end }}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
{{ printf `<atom:link href="%s" rel="self" type="application/rss+xml"/>` ($page.Permalink | safeURL) | safeHTML }}
{{ with $html }}
{{ printf `<atom:link href="%s" rel="alternate" type="%s"/>` (.Permalink | safeURL) .MediaType | safeHTML }}
{{ end }}
{{ with $copyright }}
<copyright>{{ . }}</copyright>
{{ end }}
<description>{{ $description }}</description>
{{ with $language }}
<language>{{ . }}</language>
{{ end }}
{{ with $lastbuilddate }}
<lastBuildDate>{{ . }}</lastBuildDate>
{{ end }}
<link>{{ $link }}</link>
{{ with $managingeditor }}
<managingEditor>{{ . }}</managingEditor>
{{ end }}
<title>{{ $title }}</title>
{{ with $webmaster }}
<webMaster>{{ . }}</webMaster>
{{ end }}
{{ range $subpage := $subpages }}
<item>
{{ $authors := partial "paige/authors.html" . }}
{{ $description := .Content }}
{{ $guid := "" }}
{{ $paramlink := and .Params.link (not (.Param "paige.feed.link_to_page")) }}
{{ $permalink := false }}
{{ $pubdate := .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 MST" }}
{{ $title := .Title | markdownify | plainify }}
{{ $link := cond $paramlink .Params.link .Permalink }}
{{ with $authors }}
{{ $primary := index . 0 }}
{{ $author := "" }}
{{ if and $primary.name $primary.email }}
{{ $author = printf `%s <%s>` $primary.name $primary.email }}
{{ else if $primary.email }}
{{ $author = $primary.email }}
{{ end }}
<author>{{ $author }}</author>
{{ end }}
{{ if $description }}
{{ if $paramlink }}
{{ $link := or (.Param "paige.feed.page_link" | markdownify) "⏎" }}
{{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink $title $link }}
{{ $description = print $description $footer }}
{{ end }}
{{ end }}
{{ if not $description }}
{{ $description = .Description | markdownify}}
{{ end }}
<description>{{ printf "<![CDATA[%s]]>" $description | safeHTML }}</description>
{{ if .Params.id }}
{{ $guid = .Params.id }}
{{ else if not .Date.IsZero }}
{{ $guid = printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.Date.Format "2006-01-02") (.Date.Format "2006-01-02T15:04:05Z07:00") }}
{{ else }}
{{ $guid = .RelPermalink }}
{{ $permalink = false }}
{{ end }}
{{ with index $guids $guid }}
{{ warnf "layouts/_default/rss.xml: Pages %s and %s have the same GUID" . $subpage.RelPermalink }}
{{ end }}
{{ $guids = merge (dict $guid .RelPermalink) $guids }}
<guid {{ if not $permalink }} isPermaLink="false" {{ end }}>{{ $guid }}</guid>
{{ with $link }}
<link>{{ . }}</link>
{{ end }}
{{ with $pubdate }}
<pubDate>{{ . }}</pubDate>
{{ end }}
{{ with $title }}
<title>{{ . }}</title>
{{ end }}
{{ if and (not .Description) (not .Title) }}
{{ warnf "layouts/_default/rss.xml: Page %s does not have a title or description" .RelPermalink }}
{{ end }}
</item>
{{ end }}
</channel>
</rss>