{{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.searchSections -}}
{{- $title := lower .Title -}}
{{- $pages := slice -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $what := printf ".Params.%s" $title -}}
{{- if or (eq $title "about") (eq $title "featured") -}}
{{- $pages = where $posts $what "eq" true -}}
{{- else if or (eq $title "tags") (eq $title "categories") -}}
{{- $pages = $posts -}}
{{- else if eq $title "events" -}}
{{- $pages = where $posts ".Params.when" "ne" nil -}}
{{- else -}}
{{- $pages = .Data.Pages -}}
{{- end -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pages = $pages.ByLastmod.Reverse -}}
{{- printf "" | safeHTML }}