hugo-theme-contentful/layouts/_default/list.atom
2020-05-13 01:41:43 +08:00

57 lines
2.2 KiB
XML

{{- /* This template was based from the Atom syndication format at IETF RFC #4287 (https://tools.ietf.org/html/rfc4287). */ -}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
{{- range .AlternativeOutputFormats }}
{{- printf "<link rel=%q type=%q href=%q/>" .Rel .MediaType .Permalink | safeHTML }}
{{- end }}
<rights>{{ with .Site.Copyright }}{{ . }}{{ else }}© {{ now.Year }} {{ with .Site.Author.name }}{{ . }}{{ end }}{{ end }}</rights>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}" type="text">Hugo</generator>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
<id>{{ "" | absLangURL }}</id>
{{- /* ICON, AHOY! */ -}}
<icon>{{ "icon.png" | absURL }}</icon>
{{ with .Site.Author }}
<author>
<name>{{ .name }}</name>
{{ with .email }}<email>{{ . }}</email>{{ end }}
</author>
{{ end }}
{{- /* Generate each valid regular pages (with as an individual entry in the feed. */ -}}
{{ $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 }}
{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }}
<entry>
<id>{{ .Permalink }}</id>
<title type="text">{{ .Title }}</title>
<link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Site.Language.Lang }}" title="{{ .Title | safeHTML }}"/>
{{- range .Params.author }}
<author>
<name>{{ .name }}<name>{{ with .email }}
<email>{{ . }}</email>{{ end }}
</author>
{{- end }}
{{- range .Params.tags }}
<category term="{{ . }}"/>
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
{{ with .Params.copyright }}
<rights type="html">{{ . | safeHTML }}<rights>
{{ end }}
<content type="html">{{ .Content | html }}</content>
</entry>
{{ end }}
</feed>