Refine rss build logic (#545)

* Add refine rss build logic

* Switch to .RelPermalink since URL is deprecated
This commit is contained in:
James Ray 2022-02-28 23:10:10 -05:00 committed by GitHub
parent 711d4c7749
commit e151dad461
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,12 @@
{{- $pctx := . -}} {{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}} {{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}} {{- if $.IsHome -}}
{{- $pages = $pctx.RegularPages -}}
{{- else if $.IsSection -}}
{{- $pages = $pctx.RegularPagesRecursive -}} {{- $pages = $pctx.RegularPagesRecursive -}}
{{- else -}} {{- else -}}
{{- $pages = $pctx.Pages -}} {{- $pages = $pctx.RegularPagesRecursive -}}
{{- end -}} {{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}} {{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}} {{- if ge $limit 1 -}}
@ -26,7 +28,7 @@
{{ 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 $pages }} {{ range $pages }}
{{- if ne .URL "search" -}} {{- if ne .RelPermalink "/search/" -}}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>