1{{- $pages := .RegularPages -}}
2{{- $pages = where $pages "Draft" false -}}
3{{- $pages = where $pages "Date" "<=" now -}}
4{{- $pages = where $pages "Params.rss" "!=" false -}}
5{{- $pages = sort $pages "Date" "desc" -}}
6{{- $pages = first 20 $pages -}}
7{{- $feed := .OutputFormats.Get "RSS" -}}
8{{- $description := .Description | default (printf "Latest photo albums from %s" site.Title) -}}
9{{- printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML -}}
10<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
11 <channel>
12 <title>{{ .Title }} | {{ site.Title }}</title>
13 <link>{{ .Permalink }}</link>
14 {{- with $feed }}
15 <atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
16 {{- end }}
17 <description>{{ $description | plainify }}</description>
18 <copyright>© {{ now.Year }} {{ site.Title }}. Licensed under {{ site.Params.license.name }} ({{ site.Params.license.url }}).</copyright>
19 <language>{{ site.Language.Locale }}</language>
20 <generator>Hugo {{ hugo.Version }}</generator>
21 <ttl>60</ttl>
22 {{- $mimeTypes := dict "jpg" "image/jpeg" "jpeg" "image/jpeg" "png" "image/png" "webp" "image/webp" }}
23 {{- range $pages }}
24 {{- $r2base := site.Params.r2BaseURL }}
25 {{- $rawLinks := findRE `href="https://[^/"]+/[^/"]+\.[a-z]+"` .Content }}
26 <item>
27 <title>{{ .Title }}</title>
28 <link>{{ .Permalink }}</link>
29 <guid isPermaLink="true">{{ .Permalink }}</guid>
30 <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
31 {{- with .Description }}
32 <description>{{ . | transform.XMLEscape | safeHTML }}</description>
33 {{- end }}
34 {{- range $rawLinks }}
35 {{- $url := . | replaceRE `^href="` "" | replaceRE `"$` "" }}
36 {{- $ext := path.Ext $url | strings.TrimPrefix "." | lower }}
37 {{- $mime := index $mimeTypes $ext | default "image/jpeg" }}
38 {{- $thumb := printf "%s/%s/%s" $r2base site.Params.r2Thumb (path.Base $url) }}
39 <media:content url="{{ $url }}" medium="image" type="{{ $mime }}">
40 <media:thumbnail url="{{ $thumb }}"/>
41 </media:content>
42 {{- end }}
43 </item>
44 {{- end }}
45 </channel>
46</rss>