diff options
Diffstat (limited to 'layouts/term.gemini_atom.xml')
| -rw-r--r-- | layouts/term.gemini_atom.xml | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/layouts/term.gemini_atom.xml b/layouts/term.gemini_atom.xml index dbe90ae..f55fe07 100644 --- a/layouts/term.gemini_atom.xml +++ b/layouts/term.gemini_atom.xml @@ -1,32 +1,34 @@ -{{- $authorName := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} -{{- end }} -{{- if not $authorName }} - {{- errorf "Missing author" }} -{{- end }} +{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }} +{{/* The XML declaration is emitted before anything else, including the + variables below, since whitespace may not precede it. */}} +{{ $authorName := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .name }} + {{ $authorName = . }} + {{ end }} + {{ else }} + {{ $authorName = . }} + {{ end }} +{{ end }} +{{ if not $authorName }} + {{ errorf "Missing author" }} +{{ end }} -{{- $authorEmail := "" }} -{{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} -{{- end -}} +{{ $authorEmail := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .email }} + {{ $authorEmail = . }} + {{ end }} + {{ end }} +{{ end }} -{{- $pages := .Data.Pages.ByPublishDate.Reverse }} -{{- $limit := .Site.Config.Services.RSS.Limit }} -{{- if ge $limit 1 }} -{{- $pages = first $limit $pages }} -{{- end -}} -{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }} +{{ $pages := .Data.Pages.ByPublishDate.Reverse }} +{{ $limit := .Site.Config.Services.RSS.Limit }} +{{ if ge $limit 1 }} +{{ $pages = first $limit $pages }} +{{ end }} <feed xmlns="http://www.w3.org/2005/Atom"> <id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id> <title>{{ .Site.Title }}</title> @@ -35,7 +37,7 @@ <link href="{{ .Permalink | strings.TrimSuffix "index.gmi" | safeURL }}" rel="alternate" /> <author> <name>{{ $authorName }}</name> - {{- with $authorEmail }} + {{ with $authorEmail }} <email>{{ . }}</email>{{ end }} </author> <generator>Hugo -- gohugo.io</generator> |
