summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-17 12:28:06 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-17 12:28:06 +0200
commitb2d2cbf868cb152f716c75e9252df517f104647c (patch)
treef120fef72344262de5af9e1fe40b01a5438728e8 /layouts
parentff90b903019907df7b19380dbfc8b7841d9688a0 (diff)
downloadgohugo-theme-ed-b2d2cbf868cb152f716c75e9252df517f104647c.tar.gz
Rework feeds/feed.atom.xml generation
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/home.atom.xml35
1 files changed, 18 insertions, 17 deletions
diff --git a/layouts/_default/home.atom.xml b/layouts/_default/home.atom.xml
index 1dda16b..8e29bf3 100644
--- a/layouts/_default/home.atom.xml
+++ b/layouts/_default/home.atom.xml
@@ -1,29 +1,32 @@
-{{ print "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>"| safeHTML }}
+{{ `<?` | safeHTML }}xml version="1.0" encoding="utf-8" standalone="yes"{{ `?>` | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
- xml:lang="{{ site.LanguageCode }}"
- xml:base="{{ site.BaseURL }}">
- <title>{{ site.Title }}</title>
- {{ with site.Params.description }}<subtitle type="html">{{ . }}</subtitle>{{ end }}
- {{ with site.Home.OutputFormats.Get "Atom" }}<link href="{{ .RelPermalink }}" rel="self" type="{{ .MediaType.Type | html }}" />{{ end }}
- {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}<icon>{{$logo.RelPermalink}}</icon>
- <logo>{{$logo.RelPermalink}}</logo>
+ xml:lang="{{ site.LanguageCode }}">
+ {{ printf `<title type="html"><![CDATA[%s]]></title>` site.Title | safeHTML }}
+ {{ with site.Params.description -}}
+ {{- printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
+ {{- end }}
+ {{ with site.Home.OutputFormats.Get "Atom" }}<link href="{{ .Permalink | absURL }}" rel="self" type="{{ .MediaType.Type | html }}" />{{ end }}
+ {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}<icon>{{ $logo.Permalink | absURL }}</icon>
+ <logo>{{ $logo.Permalink | absURL }}</logo>
{{ with site.Author.name }}<author>
- <name>{{ . }}</name>
- {{ with site.Author.email }}<email>{{ . }}</email>{{end}}
- </author>{{end}}
- {{ with site.Params.Copyright }}<rights type="text">{{ .}}</rights>{{end}}
+ {{ printf `<name type="html"><![CDATA[%s]]></name>` . | safeHTML }}
+ {{ with site.Author.email }}<email>{{ . | html }}</email>{{end}}
+ </author>{{ end }}
+ {{ with site.Params.Copyright -}}
+ {{- printf `<rights type="html"><![CDATA[%s]]></rights>` . | safeHTML -}}
+ {{- end }}
<generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>
{{ if not site.LastChange.IsZero }}<updated>{{ site.LastChange.UTC.Format site.Params.dateFormatFeed }}</updated>{{ end }}
{{ $uuid := sha1 (site.BaseURL | absURL)}}<id>urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}</id>
{{ $feedsize := site.Params.feedSize | default 25 }}
{{- range first $feedsize (where site.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections) }}
<entry>
- {{- $url := .RelPermalink }}{{ $uuid := sha1 (.Permalink | absURL)}}{{ $page := .}}
+ {{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL)}}{{ $page := .}}
<category term="{{ .Section}}" />
{{ range (.GetTerms "tags") }}<category term="{{ .LinkTitle }}" />{{ end }}
<link rel="alternate" type="type/html" href="{{ $url }}" />
- <title type="text">{{ .Title | plainify}}</title>
+ {{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<published>{{ (.PublishDate.Format site.Params.dateFormatFeed) | html }}</published>
{{ if ne .Date .Lastmod }}<updated>{{ .Lastmod.UTC.Format site.Params.dateFormatFeed }}</updated>{{ end }}
<id>urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}</id>
@@ -41,9 +44,7 @@
{{ end }}
{{- end }}
{{ end }}
- <summary type="html">
- {{ printf "<![CDATA[%s]]>" .Summary | chomp | safeHTML }}
- </summary>
+ {{ printf `<summary type="html"><![CDATA[%s]]></summary>` .Summary | safeHTML }}
</entry>
{{- end }}
</feed>