Move feed subpage filters to main loops

master
Will Faught 5 months ago
parent 72da4b635c
commit 2cae3f6fd6

@ -8,17 +8,11 @@
{{ $limit := site.Config.Services.RSS.Limit }} {{ $limit := site.Config.Services.RSS.Limit }}
{{ $logo := $page.Param "paige.feeds.atom.logo" | absLangURL }} {{ $logo := $page.Param "paige.feeds.atom.logo" | absLangURL }}
{{ $rights := site.Copyright | markdownify }} {{ $rights := site.Copyright | markdownify }}
{{ $subpages := slice }} {{ $subpages := $page.RegularPagesRecursive.ByPublishDate.Reverse }}
{{ $subtitle := $page.Description | markdownify }} {{ $subtitle := $page.Description | markdownify }}
{{ $lastmod := site.Lastmod.Format $date }} {{ $lastmod := site.Lastmod.Format $date }}
{{ range $page.RegularPagesRecursive.ByPublishDate.Reverse }}
{{ if not (.Param "paige.exclude_feeds") }}
{{ $subpages = $subpages | append . }}
{{ end }}
{{ end }}
{{ if gt $limit 0 }} {{ if gt $limit 0 }}
{{ $subpages = first $limit $subpages }} {{ $subpages = first $limit $subpages }}
{{ end }} {{ end }}
@ -99,94 +93,96 @@
<updated>{{ $lastmod }}</updated> <updated>{{ $lastmod }}</updated>
{{ range $subpage := $subpages }} {{ range $subpage := $subpages }}
<entry> {{ if not (.Param "paige.exclude_feeds") }}
{{ $content := .Content }} <entry>
{{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }} {{ $content := .Content }}
{{ $id := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") .RelPermalink }} {{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }}
{{ $lastmod := .Lastmod.Format $date }} {{ $id := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") .RelPermalink }}
{{ $published := cond (not .PublishDate.IsZero) (.PublishDate.Format $date) "" }} {{ $lastmod := .Lastmod.Format $date }}
{{ $summary := markdownify .Description }} {{ $published := cond (not .PublishDate.IsZero) (.PublishDate.Format $date) "" }}
{{ $title := markdownify .Title }} {{ $summary := markdownify .Description }}
{{ $title := markdownify .Title }}
{{ $link := cond $external .Params.link .Permalink }} {{ $link := cond $external .Params.link .Permalink }}
{{ if and $content $external }} {{ if and $content $external }}
{{ $text := or (.Param "paige.feeds.page_link" | markdownify) "⏎" }} {{ $text := or (.Param "paige.feeds.page_link" | markdownify) "⏎" }}
{{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink (htmlEscape .Title) $text | safeHTML }} {{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink (htmlEscape .Title) $text | safeHTML }}
{{ $content = print $content $footer }}
{{ end }}
{{ if not $content }} {{ $content = print $content $footer }}
{{ $content = markdownify .Description }} {{ end }}
{{ end }}
{{ if not $title }}
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a title. The atom output requires a title. Either set the page's title parameter, or disable the atom output." .RelPermalink }}
{{ end }}
{{ if .Lastmod.IsZero }} {{ if not $content }}
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a modified date. The atom output requires a modified date. Either set the page's date parameter, or set the page's paige.feeds.exclude parameter to true, or disable the atom output." .RelPermalink }} {{ $content = markdownify .Description }}
{{ end }} {{ end }}
{{ with partial "paige/func-authors.html" . }} {{ if not $title }}
{{ range . }} {{ warnf "layouts/_default/list.atom.xml: Page %s does not have a title. The atom output requires a title. Either set the page's title parameter, or disable the atom output." .RelPermalink }}
<author> {{ end }}
{{ with .Params.paige.author.email }}
<email>{{ . }}</email>
{{ end }}
{{ with .Params.paige.author.name }} {{ if .Lastmod.IsZero }}
<name>{{ . }}</name> {{ warnf "layouts/_default/list.atom.xml: Page %s does not have a modified date. The atom output requires a modified date. Either set the page's date parameter, or set the page's paige.feeds.exclude parameter to true, or disable the atom output." .RelPermalink }}
{{ end }} {{ end }}
{{ with .Params.paige.author.url }} {{ with partial "paige/func-authors.html" . }}
<uri>{{ . }}</uri> {{ range . }}
{{ end }} <author>
</author> {{ with .Params.paige.author.email }}
<email>{{ . }}</email>
{{ end }}
{{ with .Params.paige.author.name }}
<name>{{ . }}</name>
{{ end }}
{{ with .Params.paige.author.url }}
<uri>{{ . }}</uri>
{{ end }}
</author>
{{ end }}
{{ end }} {{ end }}
{{ end }}
{{ with $content }} {{ with $content }}
<content type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</content> <content type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</content>
{{ end }} {{ end }}
<id>{{ $id }}</id> <id>{{ $id }}</id>
{{ range .OutputFormats }} {{ range .OutputFormats }}
{{ $rel := cond (eq .Rel "canonical") "alternate" .Rel }} {{ $rel := cond (eq .Rel "canonical") "alternate" .Rel }}
{{ if or (eq $rel "alternate") (eq $rel "enclosure") (eq $rel "related") (eq $rel "via") }} {{ if or (eq $rel "alternate") (eq $rel "enclosure") (eq $rel "related") (eq $rel "via") }}
{{ $href := cond (and (eq $rel "alternate") (eq .MediaType.Type "text/html")) $link .Permalink }} {{ $href := cond (and (eq $rel "alternate") (eq .MediaType.Type "text/html")) $link .Permalink }}
<link href="{{ $href }}" rel="{{ $rel }}" type="{{ .MediaType }}"/> <link href="{{ $href }}" rel="{{ $rel }}" type="{{ .MediaType }}"/>
{{ end }}
{{ end }} {{ end }}
{{ end }}
{{ range $t := .Translations }} {{ range $t := .Translations }}
{{ range .OutputFormats }} {{ range .OutputFormats }}
{{ if or (eq .Rel "alternate") (eq .Rel "enclosure") (eq .Rel "related") (eq .Rel "via") }} {{ if or (eq .Rel "alternate") (eq .Rel "enclosure") (eq .Rel "related") (eq .Rel "via") }}
<link href="{{ .Permalink }}" hreflang="{{ $t.Lang }}" rel="{{ .Rel }}" type="{{ .MediaType }}"/> <link href="{{ .Permalink }}" hreflang="{{ $t.Lang }}" rel="{{ .Rel }}" type="{{ .MediaType }}"/>
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }}
{{ with $published }} {{ with $published }}
<published>{{ . }}</published> <published>{{ . }}</published>
{{ end }} {{ end }}
{{ with $rights }} {{ with $rights }}
<rights type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</rights> <rights type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</rights>
{{ end }} {{ end }}
{{ with $summary }} {{ with $summary }}
<summary type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</summary> <summary type="html">{{ printf "<![CDATA[%s]]>" . | safeHTML }}</summary>
{{ end }} {{ end }}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }} {{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
<updated>{{ $lastmod }}</updated> <updated>{{ $lastmod }}</updated>
</entry> </entry>
{{ end }}
{{ end }} {{ end }}
</feed> </feed>

@ -8,16 +8,10 @@
{{ $limit := site.Config.Services.RSS.Limit }} {{ $limit := site.Config.Services.RSS.Limit }}
{{ $link := ($page.AlternativeOutputFormats.Get "html").Permalink }} {{ $link := ($page.AlternativeOutputFormats.Get "html").Permalink }}
{{ $master := $page.Param "paige.feeds.rss.web_master" }} {{ $master := $page.Param "paige.feeds.rss.web_master" }}
{{ $subpages := slice }} {{ $subpages := $page.RegularPagesRecursive.ByPublishDate.Reverse }}
{{ $lastmod := site.Lastmod.Format $date }} {{ $lastmod := site.Lastmod.Format $date }}
{{ range $page.RegularPagesRecursive.ByPublishDate.Reverse }}
{{ if not (.Param "paige.exclude_feeds") }}
{{ $subpages = $subpages | append . }}
{{ end }}
{{ end }}
{{ if gt $limit 0 }} {{ if gt $limit 0 }}
{{ $subpages = $subpages | first $limit }} {{ $subpages = $subpages | first $limit }}
{{ end }} {{ end }}
@ -87,68 +81,70 @@
{{ end }} {{ end }}
{{ range $subpages }} {{ range $subpages }}
<item> {{ if not (.Param "paige.exclude_feeds") }}
{{ $author := "" }} <item>
{{ $authors := partial "paige/func-authors.html" . }} {{ $author := "" }}
{{ $description := .Content }} {{ $authors := partial "paige/func-authors.html" . }}
{{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }} {{ $description := .Content }}
{{ $guid := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") (cond (.Params.id | not) .RelPermalink .Params.id) }} {{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }}
{{ $published := .PublishDate.Format $date }} {{ $guid := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") (cond (.Params.id | not) .RelPermalink .Params.id) }}
{{ $title := .Title | markdownify | plainify | htmlUnescape }} {{ $published := .PublishDate.Format $date }}
{{ $title := .Title | markdownify | plainify | htmlUnescape }}
{{ $link := cond $external .Params.link .Permalink }}
{{ $link := cond $external .Params.link .Permalink }}
{{ with $authors }}
{{ $primary := index . 0 }} {{ with $authors }}
{{ $primary := index . 0 }}
{{ if and $primary.Params.paige.author.email $primary.Params.paige.author.name }}
{{ $author = printf "%s (%s)" $primary.Params.paige.author.email $primary.Params.paige.author.name }} {{ if and $primary.Params.paige.author.email $primary.Params.paige.author.name }}
{{ else if $primary.Params.email }} {{ $author = printf "%s (%s)" $primary.Params.paige.author.email $primary.Params.paige.author.name }}
{{ $author = $primary.Params.email }} {{ else if $primary.Params.email }}
{{ $author = $primary.Params.email }}
{{ end }}
{{ end }} {{ end }}
{{ end }}
{{ if and $description $external }} {{ if and $description $external }}
{{ $text := or (.Param "paige.feeds.page_link" | markdownify) "⏎" }} {{ $text := or (.Param "paige.feeds.page_link" | markdownify) "⏎" }}
{{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink (htmlEscape $title) $text | safeHTML }} {{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink (htmlEscape $title) $text | safeHTML }}
{{ $description = print $description $footer }} {{ $description = print $description $footer }}
{{ end }} {{ end }}
{{ if not $description }} {{ if not $description }}
{{ $description = .Description | markdownify }} {{ $description = .Description | markdownify }}
{{ end }} {{ end }}
{{ $description = replaceRE `<a href="#fn:(\d+)" class="footnote-ref" role="doc-noteref">` (printf `<a href="%s#fn:$1" class="footnote-ref" role="doc-noteref">` .Permalink) $description }} {{ $description = replaceRE `<a href="#fn:(\d+)" class="footnote-ref" role="doc-noteref">` (printf `<a href="%s#fn:$1" class="footnote-ref" role="doc-noteref">` .Permalink) $description }}
{{ $description = replaceRE `<a href="#fnref:(\d+)" class="footnote-backref" role="doc-backlink">` (printf `<a href="%s#fnref:$1" class="footnote-backref" role="doc-backlink">` .Permalink) $description }} {{ $description = replaceRE `<a href="#fnref:(\d+)" class="footnote-backref" role="doc-backlink">` (printf `<a href="%s#fnref:$1" class="footnote-backref" role="doc-backlink">` .Permalink) $description }}
{{ if and (not $description) (not $title) }} {{ if and (not $description) (not $title) }}
{{ warnf "layouts/_default/rss.xml: Page %s does not have a title or description. The rss output requires a title or description. Either set the page's title or description parameters, or disable the rss output." .RelPermalink }} {{ warnf "layouts/_default/rss.xml: Page %s does not have a title or description. The rss output requires a title or description. Either set the page's title or description parameters, or disable the rss output." .RelPermalink }}
{{ end }} {{ end }}
{{ with $author }} {{ with $author }}
<author>{{ . }}</author> <author>{{ . }}</author>
{{ end }} {{ end }}
{{ with $description }} {{ with $description }}
<description>{{ printf "<![CDATA[%s]]>" . | safeHTML }}</description> <description>{{ printf "<![CDATA[%s]]>" . | safeHTML }}</description>
{{ end }} {{ end }}
<guid isPermaLink="false">{{ $guid }}</guid> <guid isPermaLink="false">{{ $guid }}</guid>
{{ with $link }} {{ with $link }}
<link>{{ . }}</link> <link>{{ . }}</link>
{{ end }} {{ end }}
{{ with $published }} {{ with $published }}
<pubDate>{{ . }}</pubDate> <pubDate>{{ . }}</pubDate>
{{ end }} {{ end }}
{{ with $title }} {{ with $title }}
<title>{{ . }}</title> <title>{{ . }}</title>
{{ end }} {{ end }}
</item> </item>
{{ end }}
{{ end }} {{ end }}
</channel> </channel>
</rss> </rss>

Loading…
Cancel
Save