redstrate.com/themes/red/layouts/art/rss.xml
Joshua Goins 281a6c6255
All checks were successful
Deploy / Deploy Website (push) Successful in 35s
Add new art, fixup art RSS
Sensitive media now show up in the RSS feed, and comics are shown with
all of their panels.
2025-05-04 11:12:31 -04:00

120 lines
5.2 KiB
XML

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPagesRecursive -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom"
xml:base="{{ .Site.BaseURL }}">
<channel>
<title>{{ .Site.Params.author }}'s Art</title>
<link>{{ .Permalink }}</link>
<description>Feed of the art that I make!</description>
{{ with .Site.LanguageCode }}
<language>{{.}}</language>
{{end}}
{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>
{{end}}
{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end }}
<docs>https://www.rssboard.org/rss-specification</docs>
{{ with resources.Get "rss-image.png" }}
<image>
<url>{{ .Permalink }}</url>
<title>{{ $.Site.Params.author }}'s Art</title>
<link>{{ $.Permalink }}</link>
<width>100</width>
<height>100</height>
</image>
{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range $pages }}
{{ $isguest := (.Param "guest") }}
{{ $exclude := (.Param "excludefeed") }}
{{ if (and (not $isguest) (not $exclude)) }}
<item>
{{ with .Title }}
<title>{{ . }}</title>
{{ else }}
<title>Untitled Artwork</title>
{{ end }}
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ .Permalink }}</guid>
{{ with .Summary }}
<description>{{ "<![CDATA[" | safeHTML }} {{ . | safeHTML }}]]></description>
{{ else }}
<description>This artwork has no description.</description>
{{ end }}
{{ with $.Site.Params.author }}
<author>{{ . }}</author>
{{ end }}
<content:encoded>{{ "<![CDATA[" | safeHTML }}
{{/* Partial used to display a thumbnail of an artwork. */}}
{{ $full := printf "%s/thumb/%s.avif" $.Site.Params.image_host .Params.slug }}
{{ $jpeg := printf "%s/thumb/%s.jpg" $.Site.Params.image_host .Params.slug }}
<a aria-label="Gallery Item" class="no-decoration grid-item" href="{{ .Permalink }}">
{{ $title := .Title }}
{{ $year := .Date.Format "2006" }}
{{ if .Params.comic }}
{{ range .Params.pages }}
{{ $full := printf "%s/art/%s.avif" $.Site.Params.image_host .filename }}
{{ $jpeg := printf "%s/art/%s.jpg" $.Site.Params.image_host .filename}}
<picture>
<source srcset="{{ $full }}" type="image/avif"/>
<img style="display: block; max-height: 500px; margin-left: auto; margin-right: auto; width: auto; max-width: 100%; height: auto" alt="{{ .alt_text }}" src="{{ $jpeg }}"/>
</picture>
{{ end }}
{{ else }}
<picture>
<source srcset="{{ $full }}" type="image/avif" width="{{ $.Params.thumb_width }}" height="{{ $.Params.thumb_height }}"/>
<img style="display: block; max-height: 500px; margin-left: auto; margin-right: auto; width: auto; max-width: 100%; height: auto" alt="{{ $.Params.alt_text }}" title="{{ $title }} ({{ $year }})" width="{{ $.Params.thumb_width }}" height="{{ $.Params.thumb_height }}" src="{{ $jpeg }}"/>
</picture>
{{ end }}
</a>
{{ with .Params.program }}
<p><b>Created with:</b> {{ . }}</p>
{{ end }}
{{ with .Content }}
<p>{{ . | safeHTML }}</p>
{{ else }}
<p>This artwork has no additional commentary.</p>
{{ end }}]]>
</content:encoded>
</item>
{{ end }}
{{ end }}
</channel>
</rss>