1

Correction du flux RSS

This commit is contained in:
2026-04-03 11:32:51 +02:00
parent dda4d07b03
commit 4cca3165b7
3 changed files with 25 additions and 6 deletions

View File

@@ -0,0 +1,17 @@
{{- $pages := .pages | default (slice) -}}
{{- $filtered := slice -}}
{{- range $page := $pages -}}
{{- if isset $page.Params "date" -}}
{{- $frontmatter := "" -}}
{{- with $page.File -}}
{{- $source := readFile (printf "content/%s" .Path) -}}
{{- $frontmatter = delimit (findRE `(?s)^---\r?\n.*?\r?\n---` $source 1) "" -}}
{{- end -}}
{{- if gt (len (findRE `(?m)^date:\s*['"]?\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}['"]?\s*$` $frontmatter 1)) 0 -}}
{{- $filtered = $filtered | append $page -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $filtered -}}

View File

@@ -20,7 +20,8 @@
{{- $pages = $pctx.Pages -}} {{- $pages = $pctx.Pages -}}
{{- end -}} {{- end -}}
{{- $pages = $pages.ByLastmod.Reverse -}} {{- $pages = partial "rss/pages.html" (dict "pages" $pages) -}}
{{- $pages = $pages.ByPublishDate.Reverse -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}} {{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}} {{- if ge $limit 1 -}}
{{- $pages = first $limit $pages -}} {{- $pages = first $limit $pages -}}
@@ -39,8 +40,8 @@
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }} <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }} <copyright>{{ . }}</copyright>{{ end }}{{ if gt (len $pages) 0 }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ (index $pages 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- 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 }}

View File

@@ -20,7 +20,8 @@
{{- $pages = $pctx.Pages }} {{- $pages = $pctx.Pages }}
{{- end }} {{- end }}
{{- $pages = $pages.ByLastmod.Reverse }} {{- $pages = partial "rss/pages.html" (dict "pages" $pages) }}
{{- $pages = $pages.ByPublishDate.Reverse }}
{{- $limit := .Site.Config.Services.RSS.Limit }} {{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }} {{- if ge $limit 1 }}
{{- $pages = first $limit $pages }} {{- $pages = first $limit $pages }}
@@ -39,8 +40,8 @@
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }} <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }} <copyright>{{ . }}</copyright>{{ end }}{{ if gt (len $pages) 0 }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ (index $pages 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- 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 }}