Merge branch 'fix-rss-pctx' of https://github.com/nella17/hugo-theme-stack into nella17-fix-rss-pctx

This commit is contained in:
Jimmy Cai 2022-03-05 17:13:42 +00:00 committed by GitHub
commit 72629cf476

View file

@ -1,9 +1,15 @@
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}} {{- $pctx := . -}}
{{- $notHidden := where .Site.RegularPages "Params.hidden" "!=" true -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $filtered := ($pages | intersect $notHidden) -}} {{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $pages := where $pages "Params.hidden" "!=" true -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}} {{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}} {{- if ge $limit 1 -}}
{{- $filtered = $filtered | first $limit -}} {{- $pages = $pages | first $limit -}}
{{- 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">
@ -20,7 +26,7 @@
{{- with .OutputFormats.Get "RSS" -}} {{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ range $filtered }} {{ range $pages }}
{{- $content := safeHTML (.Summary | html) -}} {{- $content := safeHTML (.Summary | html) -}}
{{- if .Site.Params.rssFullContent -}} {{- if .Site.Params.rssFullContent -}}
{{- $content = safeHTML (.Content | html) -}} {{- $content = safeHTML (.Content | html) -}}