From 1867dc34c3f94b64580ab0b088012954807bfced Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 17 May 2022 15:46:41 +0200 Subject: Add RSS 2.0 support --- layouts/_default/home.atom.xml | 22 ++++++++++----------- layouts/_default/home.feed.xml | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 layouts/_default/home.feed.xml (limited to 'layouts') 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 }} +{{ safeHTML "" }} {{ printf `<![CDATA[%s]]>` site.Title | safeHTML }} - {{ with site.Params.description -}} - {{- printf `` . | safeHTML }} - {{- end }} - {{ with site.Home.OutputFormats.Get "Atom" }}{{ end }} + {{ with site.Params.description }}{{ printf `` . | safeHTML }}{{ end }} + + {{ with site.Home.OutputFormats.Get "ATOM" }}{{ end }} + {{ with site.Home.OutputFormats.Get "FEED"}}{{end}} {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}{{ $logo.Permalink | absURL }} {{ $logo.Permalink | absURL }} {{ with site.Author.name }} {{ printf `` . | safeHTML }} - {{ with site.Author.email }}{{ . | html }}{{end}} + {{ with site.Author.email }}{{ . | html }}{{ end }} {{ end }} - {{ with site.Params.Copyright -}} - {{- printf `` . | safeHTML -}} - {{- end }} + {{ with site.Params.Copyright }}{{ printf `` . | safeHTML }}{{ end }} Hugo {{ if not site.LastChange.IsZero }}{{ site.LastChange.UTC.Format site.Params.dateFormatFeed }}{{ end }} - {{ $uuid := sha1 (site.BaseURL | absURL)}}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 }} + {{ $uuid := sha1 (site.BaseURL | absURL) }}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 }} {{ $feedsize := site.Params.feedSize | default 25 }} {{- range first $feedsize (where site.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections) }} - {{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL)}}{{ $page := .}} - + {{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL) }}{{ $page := . }} + {{ range (.GetTerms "tags") }}{{ end }} {{ printf `<![CDATA[%s]]>` .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 "" }} + + + {{ printf `<![CDATA[%s RSS]]>` site.Title | safeHTML }} + + {{ "/" | absURL }} + {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }} + + {{ $logo.Permalink | absURL }} + {{ printf `<![CDATA[%s RSS]]>` site.Title | safeHTML }} + {{ "/" | absURL }} + {{ $logo.Width }} + {{ $logo.Height }} + + + {{ with site.Home.OutputFormats.Get "FEED"}}{{end}} + {{ with site.Home.OutputFormats.Get "ATOM"}}{{end}} + {{ with site.Params.description }}{{ printf `` . | safeHTML }}{{ end }} + Hugo + {{ with site.Author.name }}{{ printf `` . | safeHTML }}{{ end }} + {{ with site.LanguageCode }}{{ . }}{{ end }} + {{ with site.Params.Copyright }}{{ printf `` . | safeHTML }}{{ end }} + {{ if not site.LastChange.IsZero }}{{ site.LastChange.UTC.Format site.Params.dateFormatRFC822Z | html }}{{ end }} + {{ $feedsize := site.Params.feedSize | default 25 }} + {{- range first $feedsize (where site.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections) }} + + {{ printf `<![CDATA[%s]]>` .Title | safeHTML }} + {{ .Permalink | absURL }}{{ $date := .PublishDate.UTC }} + {{ $date.Format site.Params.dateFormatRFC822Z | html }} + {{ .Section }} + {{ range (.GetTerms "tags") }}{{ .LinkTitle }}{{end}} + {{ md5 .Permalink }} + {{ printf `` .Summary | safeHTML }} + + {{ end }} + -- cgit v1.2.3