Refactor RSS feed layout to define allowed sections and improve content processing
Some checks are pending
/ test (push) Waiting to run
Some checks are pending
/ test (push) Waiting to run
This commit is contained in:
parent
44e2eca6ad
commit
88d00d59b3
1 changed files with 20 additions and 4 deletions
|
@ -30,6 +30,9 @@
|
|||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Define allowed sections for RSS feed */}}
|
||||
{{- $allowedSections := slice "blog" "collection" "livres" "recettes" }}
|
||||
|
||||
{{- $pctx := . }}
|
||||
{{- if .IsHome }}{{ $pctx = site }}{{ end }}
|
||||
{{- $pages := slice }}
|
||||
|
@ -66,16 +69,29 @@
|
|||
{{- end }}
|
||||
{{- range $pages }}
|
||||
{{- $section := .Section }}
|
||||
{{- if and (ne .Layout `search`) (ne .Layout `archives`) (ne $section `a-propos`) (ne $section `blogroll`) (ne $section `contact`) (ne $section `colophon`) }}
|
||||
{{- if in $allowedSections $section }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description>
|
||||
{{- if and site.Params.ShowFullTextinRSS .Content }}
|
||||
<content:encoded>{{ (printf "<![CDATA[%s]]>" .Content) | safeHTML }}</content:encoded>
|
||||
|
||||
{{- /* Process content to fix image URLs */}}
|
||||
{{- $summary := "" }}
|
||||
{{- with .Description }}
|
||||
{{- $summary = . }}
|
||||
{{- else }}
|
||||
{{- $summary = .Summary }}
|
||||
{{- end }}
|
||||
|
||||
{{- $baseURLWithoutTrailing := strings.TrimSuffix "/" site.BaseURL }}
|
||||
<description>{{ $summary | html }}</description>
|
||||
|
||||
{{- if site.Params.ShowFullTextinRSS }}
|
||||
{{- $content := .Content }}
|
||||
{{- $content := $content | replaceRE `src="(/[^"]*)"` (printf `src="%s$1"` $baseURLWithoutTrailing) }}
|
||||
<content:encoded>{{ (printf "<![CDATA[%s]]>" $content) | safeHTML }}</content:encoded>
|
||||
{{- end }}
|
||||
</item>
|
||||
{{- end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue