1

Fixed Hugo's crappy default RSS template

This commit is contained in:
2025-04-01 14:39:14 +02:00
parent 04728136ca
commit a8d503f14a

View File

@@ -1,18 +1,9 @@
{{- $authorEmail := "" }} {{- $authorEmail := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .email }}
{{- $authorEmail = . }}
{{- end }}
{{- end }}
{{- end }}
{{- $authorName := "" }} {{- $authorName := "" }}
{{- with site.Params.author }} {{- with site.Params.author }}
{{- if reflect.IsMap . }} {{- if reflect.IsMap . }}
{{- with .name }} {{- with .email }}{{- $authorEmail = . }}{{- end }}
{{- $authorName = . }} {{- with .name }}{{- $authorName = . }}{{- end }}
{{- end }}
{{- else }} {{- else }}
{{- $authorName = . }} {{- $authorName = . }}
{{- end }} {{- end }}
@@ -20,15 +11,18 @@
{{- $pctx := . }} {{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }} {{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }} {{- $pages := slice }}
{{- if or $.IsHome $.IsSection }} {{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }} {{- $pages = $pctx.RegularPages }}
{{- else }} {{- else }}
{{- $pages = $pctx.Pages }} {{- $pages = $pctx.Pages }}
{{- end }} {{- end }}
{{- $pages = $pages.ByLastmod.Reverse }}
{{- $limit := .Site.Config.Services.RSS.Limit }} {{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }} {{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }} {{- $pages = first $limit $pages }}
{{- end }} {{- end }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">