InkSoul/themes/meme_cdn/layouts/index.sectionsrss.xml

87 lines
4.5 KiB
XML

{{ `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }}
<!-- Reference: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml -->
<!-- Reference: https://github.com/kaushalmodi/hugo-atom-feed/blob/master/layouts/_default/list.atom.xml -->
<!-- Reference: https://validator.w3.org/feed/docs/rss2.html -->
<!-- Reference: https://developers.google.com/gdata/docs/1.0/reference -->
<!-- Reference: https://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared -->
<!-- Reference: https://en.wikipedia.org/wiki/RSS -->
{{- $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end }}
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link>
<description>{{ .Site.Params.siteDescription }}</description>
<generator>Hugo {{ hugo.Version }} https://gohugo.io/</generator>
{{ with .Site.LanguageCode }}
<language>{{ . }}</language>
{{ end }}
{{ with .Site.Author.email }}
<managingEditor>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</managingEditor>
{{ end }}
{{ with .Site.Author.email }}
<webMaster>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</webMaster>
{{ end }}
{{ with .Site.Copyright }}
<copyright>{{ . | plainify | htmlUnescape }}</copyright>
{{ end }}
<lastBuildDate>{{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</lastBuildDate>
{{ with .OutputFormats.Get "SectionsRSS" }}
<atom:link rel="self" type="{{ .MediaType }}" href="{{ .Permalink }}" />
{{ end }}
{{ range $pages }}
{{ $page := . }}
{{- $author := partial "utils/author.html" $page -}}
<item>
<title>{{ (partial "utils/title.html" (dict "$" . "title" .Title)).rawTitle }}</title>
<link>{{ .Permalink }}</link>
<guid isPermaLink="true">{{ .Permalink }}</guid>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
{{ with $author.email }}
<author>{{ . }}{{ with $author.name }} ({{ . }}){{ end }}</author>
{{ end }}
{{ with $author.copyright -}}
<copyright>{{ . | plainify | htmlUnescape }}</copyright>
{{- end }}
{{ if $.Site.Params.includeContent }}
<description>{{ partial "utils/make-links-absolute.html" (dict "$" . "content" .Content) | html }}</description>
{{ else }}
{{- $summary := .Description | default (partial "utils/summary.html" $page) -}}
<description>{{ partial "utils/make-links-absolute.html" (dict "$" . "content" $summary) | html }}</description>
{{ end }}
<!-- Sections -->
{{ if eq $.Site.Params.categoryBy "sections" }}
{{ $.Scratch.Delete "sectionDir" }}
{{ $sections := split (strings.TrimSuffix "/" .File.Dir) "/" }}
{{ range $sections }}
{{ $section := . }}
{{ $.Scratch.Add "sectionDir" (printf `/%s` .) }}
{{ with $.Site.GetPage ($.Scratch.Get "sectionDir") }}
{{ if (eq .Kind "section") }}
<category domain="{{ .Permalink }}">{{ $section }}</category>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<!-- Taxonomies -->
{{ with $.Site.Taxonomies }}
{{ range $taxonomy, $terms := . }}
{{ with $page.Param $taxonomy }}
{{ range $index, $term := . }}
{{ $url := urls.Parse ($term | urlize) }}
{{ $path := $url.Path }}
{{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $path) }}
<category domain="{{ .Permalink }}">{{ .Title | default $term }}</category>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</item>
{{ end }}
</channel>
</rss>