summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-17 15:46:41 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-17 15:46:41 +0200
commit1867dc34c3f94b64580ab0b088012954807bfced (patch)
treea1be91665e6c6fff14122dd5e67830deb6212733 /layouts
parentb2d2cbf868cb152f716c75e9252df517f104647c (diff)
downloadgohugo-theme-ed-1867dc34c3f94b64580ab0b088012954807bfced.tar.gz
Add RSS 2.0 support
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/home.atom.xml22
-rw-r--r--layouts/_default/home.feed.xml44
2 files changed, 54 insertions, 12 deletions
diff --git a/layouts/_default/home.atom.xml b/layouts/_default/home.atom.xml
index 8e29bf3..5368ab7 100644
--- a/layouts/_default/home.atom.xml
+++ b/layouts/_default/home.atom.xml
@@ -1,29 +1,27 @@
-{{ `<?` | safeHTML }}xml version="1.0" encoding="utf-8" standalone="yes"{{ `?>` | safeHTML }}
+{{ safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }}
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
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 }}
+ {{ with site.Params.description }}{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}{{ end }}
+ <link href="{{ "/" | absURL }}" type="text/html" />
+ {{ with site.Home.OutputFormats.Get "ATOM" }}<link href="{{ .Permalink | absURL }}" rel="self" type="{{ .MediaType.Type | html }}" />{{ end }}
+ {{ with site.Home.OutputFormats.Get "FEED"}}<link href="{{ .Permalink | absURL }}" rel="alternate" 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>
{{ printf `<name type="html"><![CDATA[%s]]></name>` . | safeHTML }}
- {{ with site.Author.email }}<email>{{ . | html }}</email>{{end}}
+ {{ with site.Author.email }}<email>{{ . | html }}</email>{{ end }}
</author>{{ end }}
- {{ with site.Params.Copyright -}}
- {{- printf `<rights type="html"><![CDATA[%s]]></rights>` . | safeHTML -}}
- {{- 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>
+ {{ $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 := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL)}}{{ $page := .}}
- <category term="{{ .Section}}" />
+ {{- $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 }}" />
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
diff --git a/layouts/_default/home.feed.xml b/layouts/_default/home.feed.xml
new file mode 100644
index 0000000..2f33114
--- /dev/null
+++ b/layouts/_default/home.feed.xml
@@ -0,0 +1,44 @@
+{{ safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }}
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:media="http://search.yahoo.com/mrss/"
+ xml:lang="{{ site.LanguageCode }}">
+ <channel>
+ {{ printf `<title type="html"><![CDATA[%s RSS]]></title>` site.Title | safeHTML }}
+ </channel>
+ <link type="text/html">{{ "/" | absURL }}</link>
+ {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}
+ <image>
+ <url>{{ $logo.Permalink | absURL }}</url>
+ {{ printf `<title type="html"><![CDATA[%s RSS]]></title>` site.Title | safeHTML }}
+ <link>{{ "/" | absURL }}</link>
+ <width>{{ $logo.Width }}</width>
+ <height>{{ $logo.Height }}</height>
+ </image>
+ <link href="{{ "/" | absURL }}" type="text/html" />
+ {{ with site.Home.OutputFormats.Get "FEED"}}<atom:link href="{{ .Permalink | absURL }}" rel="self" type="{{ .MediaType.Type | html }}" />{{end}}
+ {{ with site.Home.OutputFormats.Get "ATOM"}}<atom:link href="{{ .Permalink | absURL }}" rel="alternate" type="{{ .MediaType.Type | html }}" />{{end}}
+ {{ with site.Params.description }}{{ printf `<description type="html"><![CDATA[%s]]></description>` . | safeHTML }}{{ end }}
+ <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>
+ {{ with site.Author.name }}{{ printf `<dc:creator type="html"><![CDATA[%s]]></dc:creator>` . | safeHTML }}{{ end }}
+ {{ with site.LanguageCode }}<language>{{ . }}</language>{{ end }}
+ {{ with site.Params.Copyright }}{{ printf `<copyright type="html"><![CDATA[%s]]></copyright>` . | safeHTML }}{{ end }}
+ {{ if not site.LastChange.IsZero }}<lastBuildDate>{{ site.LastChange.UTC.Format site.Params.dateFormatRFC822Z | html }}</lastBuildDate>{{ end }}
+ {{ $feedsize := site.Params.feedSize | default 25 }}
+ {{- range first $feedsize (where site.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections) }}
+ <item>
+ {{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
+ <link>{{ .Permalink | absURL }}</link>{{ $date := .PublishDate.UTC }}
+ <pubDate>{{ $date.Format site.Params.dateFormatRFC822Z | html }}</pubDate>
+ <category>{{ .Section }}</category>
+ {{ range (.GetTerms "tags") }}<category>{{ .LinkTitle }}</category>{{end}}
+ <guid isPermaLink="false">{{ md5 .Permalink }}</guid>
+ {{ printf `<description type="html"><![CDATA[%s]]></description>` .Summary | safeHTML }}
+ </item>
+ {{ end }}
+</rss>