gohugo-theme-bree/layouts/_default/list.feed.xml

63 lines
3.3 KiB
XML

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if $.IsHome -}}
{{- $mainSections := site.Params.mainSections | default (slice "posts") }}
{{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}}
{{- else if $.IsSection -}}
{{- $pages = $pctx.RegularPages.ByDate.Reverse -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := site.Params.feedSize | default 25 -}}
{{- $pages = $pages | first $limit -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:media="http://search.yahoo.com/mrss/"
xml:lang="{{ site.LanguageCode }}"
xml:base="{{ site.BaseURL }}">
<channel>
{{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "title.html" .) | safeHTML }}
</channel>
<link type="text/html">{{ site.BaseURL | absURL }}</link>
{{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }}{{ $logo = $logo.Resize "96x96" }}
<image>
<url>{{ $logo.Permalink | absURL }}</url>
{{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "title.html" .) | safeHTML }}
<link>{{ site.BaseURL | absURL }}</link>
<width>{{ $logo.Width }}</width>
<height>{{ $logo.Height }}</height>
</image>
{{- $output_formats := .OutputFormats }}
{{- range $output_formats -}}
{{- $rel := (or (and (eq "feed" (.Name | lower)) "self") "alternate") -}}
{{- with $output_formats.Get .Name }}
{{ printf `<atom:link href=%q rel=%q type=%q title=%q />` .RelPermalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
{{ with site.Params.description }}{{ printf `<description type="html"><![CDATA[%s]]></description>` . | safeHTML }}{{ end }}
<generator>Hugo {{ hugo.Version }}</generator>{{ with site.Author.name }}
{{ printf `<dc:creator type="html"><![CDATA[%s]]></dc:creator>` . | safeHTML }}{{ end }}{{ with site.LanguageCode }}
<language>{{ . }}</language>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "&copy;" "©" }}
<copyright>{{ $copyright | plainify }}</copyright>{{ end }}{{ if not site.LastChange.IsZero }}
<lastBuildDate>{{ site.LastChange.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{- range $pages }}
<item>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link>{{ .Permalink | absURL }}?utm_source=rss_feed</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<category>{{ .Section }}</category>{{ range (.GetTerms "tags") }}
<category>{{ .LinkTitle }}</category>{{end}}
<guid isPermaLink="false">{{ md5 .Permalink }}</guid>
{{ printf `<description type="html"><![CDATA[%s]]></description>` .Summary | safeHTML }}
</item>
{{ end }}
</rss>