XML: Prettify RSS and Atom feeds by taking care of whitespace

This commit is contained in:
hedy 2022-05-15 09:51:36 +08:00
parent d4914ef2f9
commit 67c8917d99
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 9 additions and 9 deletions

View File

@ -23,20 +23,20 @@
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range where .Site.Pages "Kind" "page" }}
{{ if or (eq .Section "posts") (eq .Section "post") }}
{{- end }}
{{- range where .Site.Pages "Kind" "page" }}
{{- if or (eq .Section "posts") (eq .Section "post") }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{- .Content | html -}}</description>
<description>{{ .Content | html }}</description>
</item>
{{ end }}
{{ end }}
{{- end }}
{{- end }}
</channel>
</rss>

View File

@ -30,6 +30,6 @@
<email>{{ $.Site.Author.email }}</email>
</author>
</entry>
{{end}}
{{- end}}
{{- end }}
{{ end }}
</feed>