hugo-geekblog/layouts/_default/list.atom.xml

74 lines
3.7 KiB
XML
Raw Normal View History

{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- $title := .Site.Title -}}
{{- if not (eq .Kind "home") }}
2022-02-06 11:46:10 +00:00
{{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
{{- end }}
<title>{{ trim ($title | plainify) "\n" | safeHTML }}</title>
{{- with .Site.Params.subtitle }}
<subtitle>{{ trim (. | plainify) "\n" | safeHTML }}</subtitle>
{{- end }}
{{- $output_formats := .OutputFormats -}}
{{- range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{- with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
{{- end }}
{{- end }}
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{- with .Site.Params.GeekblogAuthor -}}
{{- with index $.Site.Data.authors . }}
<author>
<name>{{ .name }}</name>
{{- with .email }}
<email>{{ . }}</email>
{{- end }}
</author>
{{- end }}
{{- end }}
<id>{{ .Permalink }}</id>
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- end -}}
{{- range $page := $pages }}
<entry>
<title>{{ trim (partial "utils/title" . | plainify) "\n" | safeHTML }}</title>
<link href="{{ .Permalink }}" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
<id>{{ .Permalink }}</id>
{{- with .Params.authors }}
{{- range sort . }}
{{- $author := index $.Site.Data.authors . }}
<author>
<name>{{ $author.name }}</name>
</author>
{{- end }}
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{- $img := "" -}}
{{- with ($page.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
{{- $img = printf `<img src="%s" width="%d" height="%d" alt="%s" /><br/>` $featured.Permalink $featured.Width $featured.Height (default (partial "utils/title" $page) .Params.description) -}}
{{- end }}
<content type="html">
{{ printf "%s%s" $img .Content | htmlEscape | safeHTML }}
</content>
{{- with .Site.Taxonomies }}
{{- range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
{{- with $page.Param $taxo }}
{{- $taxo_list := . -}} <!-- $taxo_list will be the tags/categories list -->
{{- with $.Site.GetPage (printf "/%s" $taxo) }}
{{- $taxonomy_page := . -}}
{{- range $taxo_list }} <!-- Below, assuming pretty URLs -->
<category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
</entry>
{{- end }}
</feed>