brainbaking/themes/brainbaking-minimal/layouts/_default/rss.xml

79 lines
3.7 KiB
XML

{{- $allowedRssSections := (slice "post") -}}
{{- $baseurl := .Site.BaseURL -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- 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\"?>\n" | safeHTML }}
{{- printf "<?xml-stylesheet type=\"text/xsl\" media=\"screen\" href=\"%spretty-feed-v3.xsl\" ?>" $baseurl | safeHTML }}
<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>{{ .Site.Params.description }} by {{ .Site.Author.name }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}
<managingEditor>{{ .Site.Author.rssmail }} ({{ with $.Site.Author.name }}{{.}}{{end}})</managingEditor>
{{ if not .Date.IsZero }}<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}{{ end }}
<image>
<url>{{ $baseurl }}img/logo-rss.jpg</url>
<title>{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link>
<width>72</width>
<height>72</height>
<description>{{ .Site.Params.description }} by {{ .Site.Author.name }}</description>
</image>
{{ range $pages }}
{{ if and (in $allowedRssSections .Section) (not (isset .Params "type")) (or (not (isset .Params "context")) (eq .Params.context "")) }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<comments>{{ .Site.Author.mastodonlink }}</comments>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<dc:creator>{{ with $.Site.Author.name }}{{.}}{{end}}</dc:creator>
<guid isPermaLink="true">{{ .Permalink }}</guid>
{{ if .Keywords }}
{{ range .Keywords }}
<category>{{ . }}</category>
{{ end }}
{{ else if .Params.tags }}
{{ range .Params.tags }}
<category domain="{{ $baseurl }}tags/{{ . }}">{{ . }}</category>
{{ end }}
{{ end }}
{{ $content := .Content }}
<!-- relative images/URLs do not work in some feed readers. Thanks, Peter. See render-image.html -->
{{ $content = replaceRE `a href="(#.*?)"` (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content }}
{{ $content = replaceRE `a href="^../(.*?)"` (printf "%s%s%s" "a href=\"" .Permalink "../$1\"") $content }}
{{ $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content }}
<description>
{{ `<![CDATA[ ` | safeHTML }}
{{ if .Params.bigimg }}
<p>
<img align="left" hspace="5" src="{{ $baseurl }}bigimg/{{ .Params.bigimg }}"/>
</p>
{{ end }}
{{ $content | safeHTML }}
<p>
By <a href="/about">{{ .Site.Author.name }}</a> on {{ .Date.Format "2 January 2006" }}.&nbsp;
<a href="mailto:{{ .Site.Author.rssmail }}?subject=Re: {{ .Title }}">Reply via email</a>.
</p>
]]>
</description>
</item>
{{ end }}
{{ end }}
</channel>
</rss>