From bdaacc46415a1619a0e54f0aa89e59b38d536e5c Mon Sep 17 00:00:00 2001 From: wurstsalat Date: Thu, 28 Mar 2024 21:08:05 +0100 Subject: [PATCH] Feed: Use Hugo's default RSS template and link to blog feed --- .../xmpp-providers/layouts/_default/rss.xml | 71 +++++++++++++++++++ themes/xmpp-providers/layouts/index.xml | 42 ----------- .../layouts/partials/footer.html | 2 +- .../xmpp-providers/layouts/partials/head.html | 2 +- .../layouts/shortcodes/feed.html | 2 +- 5 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 themes/xmpp-providers/layouts/_default/rss.xml delete mode 100644 themes/xmpp-providers/layouts/index.xml diff --git a/themes/xmpp-providers/layouts/_default/rss.xml b/themes/xmpp-providers/layouts/_default/rss.xml new file mode 100644 index 0000000..21ccf89 --- /dev/null +++ b/themes/xmpp-providers/layouts/_default/rss.xml @@ -0,0 +1,71 @@ +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + +{{- $pctx := . }} +{{- if .IsHome }}{{ $pctx = .Site }}{{ end }} +{{- $pages := slice }} +{{- if or $.IsHome $.IsSection }} +{{- $pages = $pctx.RegularPages }} +{{- else }} +{{- $pages = $pctx.Pages }} +{{- end }} +{{- $limit := .Site.Config.Services.RSS.Limit }} +{{- if ge $limit 1 }} +{{- $pages = $pages | first $limit }} +{{- end }} +{{- printf "" | safeHTML }} + + + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo -- gohugo.io + {{ site.Language.LanguageCode }}{{ with $authorEmail }} + {{.}}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} + {{ . }}{{ end }}{{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "RSS" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end }} + {{- range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} + {{ .Permalink }} + {{ .Content | transform.XMLEscape | safeHTML }} + + {{- end }} + + \ No newline at end of file diff --git a/themes/xmpp-providers/layouts/index.xml b/themes/xmpp-providers/layouts/index.xml deleted file mode 100644 index 4095b0a..0000000 --- a/themes/xmpp-providers/layouts/index.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - {{- if eq .Title .Site.Title -}} - {{- .Site.Title -}} - {{- else -}} - {{- with .Title -}} - {{- . -}} on - {{- end -}} - {{- .Site.Title -}} - {{- end -}} - - - - {{ if not .Date.IsZero }} - {{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ end }} - {{ .Permalink }} - {{ with .Site.Params.author.name }} - - {{ . }} - {{ with $.Site.Author.email }} - {{ . }} - {{end}} - - {{end}} - Hugo -- gohugo.io - {{ range where (where .Site.Pages ".Section" "blog") "Kind" "page" }} - - {{ `<![CDATA[` | safeHTML }}{{ .Title }}]]> - - {{ .Permalink }} - {{ with .Site.Params.author.name }} - - {{ . }} - - {{end}} - {{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ ` - - {{ end }} - diff --git a/themes/xmpp-providers/layouts/partials/footer.html b/themes/xmpp-providers/layouts/partials/footer.html index 887184b..74d70b9 100644 --- a/themes/xmpp-providers/layouts/partials/footer.html +++ b/themes/xmpp-providers/layouts/partials/footer.html @@ -8,7 +8,7 @@  ·   Contact  ·  -  News Feed +  News Feed  ·   Mastodon  ·  diff --git a/themes/xmpp-providers/layouts/partials/head.html b/themes/xmpp-providers/layouts/partials/head.html index bc9ac57..2db6d87 100644 --- a/themes/xmpp-providers/layouts/partials/head.html +++ b/themes/xmpp-providers/layouts/partials/head.html @@ -45,7 +45,7 @@ {{- end }} {{- end }} - + diff --git a/themes/xmpp-providers/layouts/shortcodes/feed.html b/themes/xmpp-providers/layouts/shortcodes/feed.html index ed0ab02..53cac73 100644 --- a/themes/xmpp-providers/layouts/shortcodes/feed.html +++ b/themes/xmpp-providers/layouts/shortcodes/feed.html @@ -1 +1 @@ - News Feed \ No newline at end of file + News Feed \ No newline at end of file