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.

207 lines
7.2 KiB
XML

{{ $page := . }}
{{ $authors := $page.Param "paige.feed.atom.authors" }}
{{ $format := "2006-01-02T15:04:05Z07:00" }}
{{ $html := $page.AlternativeOutputFormats.Get "html" }}
{{ $id := "" }}
{{ $ids := dict }}
{{ $language := site.LanguageCode | default site.Language.Lang }}
{{ $limit := site.Config.Services.RSS.Limit }}
{{ $pagetitle := $page.Title | markdownify }}
{{ $rights := site.Copyright | markdownify }}
{{ $sitetitle := site.Title | markdownify }}
{{ $subpages := slice }}
{{ $subtitle := $page.Description | markdownify }}
{{ $title := "" }}
{{ $updated := site.LastChange.Format $format }}
{{ if $page.Params.id }}
{{ $id = $page.Params.id }}
{{ else if not $page.Date.IsZero }}
{{ $id = printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.Date.Format "2006-01-02") (.Date.Format $format) }}
{{ else }}
{{ $id = $page.Permalink }}
{{ end }}
{{ range (cond $page.IsHome site $page).RegularPages }}
{{ if not (.Param "paige.feed.hide_page") }}
{{ $subpages = $subpages | append . }}
{{ end }}
{{ end }}
{{ if gt $limit 0 }}
{{ $subpages = $subpages | first $limit }}
{{ end }}
{{ if and $pagetitle $sitetitle }}
{{ if $page.IsHome }}
{{ $title = $pagetitle }}
{{ else }}
{{ $title = printf "%s · %s" $pagetitle $sitetitle }}
{{ end }}
{{ else if $pagetitle }}
{{ $title = $pagetitle }}
{{ else if $sitetitle }}
{{ $title = $sitetitle }}
{{ else }}
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a title" $page.RelPermalink }}
{{ end }}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
<feed {{ with $language }} xml:lang="{{ . }}" {{ end }} xmlns="http://www.w3.org/2005/Atom">
{{ range $authors }}
<author>
{{ with .email }}
<email>{{ . }}</email>
{{ end }}
{{ with .name }}
<name>{{ . }}</name>
{{ end }}
{{ with .url }}
<uri>{{ . }}</uri>
{{ end }}
</author>
{{ end }}
<id>{{ $id }}</id>
{{ range $page.OutputFormats }}
{{ $rel := .Rel }}
{{ if eq .Permalink $page.Permalink }}
{{ $rel = "self" }}
{{ else if eq $rel "canonical" }}
{{ $rel = "alternate" }}
{{ end }}
{{ if or (eq $rel "alternate") (eq $rel "enclosure") (eq $rel "related") (eq $rel "self") (eq $rel "via") }}
{{ printf `<link href="%s" rel="%s" type="%s"/>` .Permalink $rel .MediaType | safeHTML }}
{{ end }}
{{ end }}
{{ range $t := $page.Translations }}
{{ range .OutputFormats }}
{{ if or (eq .Rel "alternate") (eq .Rel "enclosure") (eq .Rel "related") (eq .Rel "via") }}
{{ printf `<link href="%s" hreflang="%s" rel="%s" type="%s"/>` .Permalink $t.Lang .Rel .MediaType | safeHTML }}
{{ end }}
{{ end }}
{{ end }}
{{ with $rights }}
<rights type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</rights>
{{ end }}
{{ with $subtitle }}
<subtitle type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML}}</subtitle>
{{ end }}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
<updated>{{ $updated }}</updated>
{{ range $subpage := $subpages }}
<entry>
{{ $content := .Content }}
{{ $id := "" }}
{{ $paramlink := and .Params.link (not (.Param "paige.feed.link_to_page")) | not | not }}
{{ $published := cond (not .PublishDate.IsZero) (.PublishDate.Format $format) "" }}
{{ $rights := site.Copyright | markdownify }}
{{ $summary := .Description | markdownify }}
{{ $title := .Title | markdownify }}
{{ $updated := .Lastmod.Format $format }}
{{ $link := cond $paramlink .Params.link .Permalink }}
{{ if and $content $paramlink }}
{{ $link := or (.Param "paige.feed.page_link" | markdownify) "⏎" }}
{{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink .Title $link }}
{{ $content = print $content $footer }}
{{ end }}
{{ if not $content }}
{{ $content = .Description | markdownify}}
{{ end }}
{{ if .Params.id }}
{{ $id = .Params.id }}
{{ else if not .Date.IsZero }}
{{ $id = printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.Date.Format "2006-01-02") (.Date.Format $format) }}
{{ else }}
{{ $id = .RelPermalink }}
{{ end }}
{{ with index $ids $id }}
{{ warnf "layouts/_default/list.atom.xml: Pages %s and %s have the same ID" . $subpage.RelPermalink }}
{{ end }}
{{ $ids = merge (dict $id .RelPermalink) $ids }}
{{ if not $title }}
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a title" .RelPermalink }}
{{ end }}
{{ if .Lastmod.IsZero }}
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a modified date" .RelPermalink }}
{{ end }}
{{ with partial "paige/authors.html" . }}
{{ range . }}
<author>
{{ with .email }}
<email>{{ . }}</email>
{{ end }}
{{ with .name }}
<name>{{ . }}</name>
{{ end }}
{{ with .url }}
<uri>{{ . }}</uri>
{{ end }}
</author>
{{ end }}
{{ end }}
{{ with $content }}
<content type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</content>
{{ end }}
<id>{{ $id }}</id>
{{ range .OutputFormats }}
{{ $rel := cond (eq .Rel "canonical") "alternate" .Rel }}
{{ if or (eq $rel "alternate") (eq $rel "enclosure") (eq $rel "related") (eq $rel "via") }}
{{ printf `<link href="%s" rel="%s" type="%s"/>` .Permalink $rel .MediaType | safeHTML }}
{{ end }}
{{ end }}
{{ range $t := .Translations }}
{{ range .OutputFormats }}
{{ if or (eq .Rel "alternate") (eq .Rel "enclosure") (eq .Rel "related") (eq .Rel "via") }}
{{ printf `<link href="%s" hreflang="%s" rel="%s" type="%s"/>` .Permalink $t.Lang .Rel .MediaType | safeHTML }}
{{ end }}
{{ end }}
{{ end }}
{{ with $published }}
<published>{{ . }}</published>
{{ end }}
{{ with $rights }}
<rights type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</rights>
{{ end }}
{{ with $summary }}
<summary type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</summary>
{{ end }}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
<updated>{{ $updated }}</updated>
</entry>
{{ end }}
</feed>