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 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- /* Define allowed sections for RSS feed */}}
|
||||||
|
{{- $allowedSections := slice "blog" "collection" "livres" "recettes" }}
|
||||||
|
|
||||||
{{- $pctx := . }}
|
{{- $pctx := . }}
|
||||||
{{- if .IsHome }}{{ $pctx = site }}{{ end }}
|
{{- if .IsHome }}{{ $pctx = site }}{{ end }}
|
||||||
{{- $pages := slice }}
|
{{- $pages := slice }}
|
||||||
|
@ -66,16 +69,29 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- range $pages }}
|
{{- range $pages }}
|
||||||
{{- $section := .Section }}
|
{{- $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>
|
<item>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<link>{{ .Permalink }}</link>
|
<link>{{ .Permalink }}</link>
|
||||||
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||||
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
|
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
|
||||||
<guid>{{ .Permalink }}</guid>
|
<guid>{{ .Permalink }}</guid>
|
||||||
<description>{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description>
|
|
||||||
{{- if and site.Params.ShowFullTextinRSS .Content }}
|
{{- /* Process content to fix image URLs */}}
|
||||||
<content:encoded>{{ (printf "<![CDATA[%s]]>" .Content) | safeHTML }}</content:encoded>
|
{{- $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 }}
|
{{- end }}
|
||||||
</item>
|
</item>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue