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

View File

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