1

Résout les images référencées par des métadonnées YAML

This commit is contained in:
2026-03-23 23:12:55 +01:00
parent e11e4ee591
commit 99f674dd9f
9 changed files with 234 additions and 86 deletions

View File

@@ -308,7 +308,25 @@
{{- $image := false -}}
{{- with $page.Params.cover -}}
{{- $image = $page.Resources.GetMatch . -}}
{{- $coverResourcePath := (urls.Parse .).Path -}}
{{- if ne $coverResourcePath "" -}}
{{- $coverPathLower := lower $coverResourcePath -}}
{{- if or (strings.HasSuffix $coverPathLower ".yaml") (strings.HasSuffix $coverPathLower ".yml") -}}
{{- $coverDataFile := $page.Resources.Get $coverResourcePath -}}
{{- if $coverDataFile -}}
{{- with $coverDataFile.Content | transform.Unmarshal -}}
{{- with index . "file" -}}
{{- $coverFilePath := strings.TrimSpace (printf "%v" .) -}}
{{- if ne $coverFilePath "" -}}
{{- $image = $page.Resources.Get $coverFilePath -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- $image = $page.Resources.Get $coverResourcePath -}}
{{- end -}}
{{- end -}}
{{- end -}}
<article>
@@ -399,7 +417,25 @@
{{- $item := . -}}
{{- $itemImage := false -}}
{{- with $item.Params.cover -}}
{{- $itemImage = $item.Resources.GetMatch . -}}
{{- $coverResourcePath := (urls.Parse .).Path -}}
{{- if ne $coverResourcePath "" -}}
{{- $coverPathLower := lower $coverResourcePath -}}
{{- if or (strings.HasSuffix $coverPathLower ".yaml") (strings.HasSuffix $coverPathLower ".yml") -}}
{{- $coverDataFile := $item.Resources.Get $coverResourcePath -}}
{{- if $coverDataFile -}}
{{- with $coverDataFile.Content | transform.Unmarshal -}}
{{- with index . "file" -}}
{{- $coverFilePath := strings.TrimSpace (printf "%v" .) -}}
{{- if ne $coverFilePath "" -}}
{{- $itemImage = $item.Resources.Get $coverFilePath -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- $itemImage = $item.Resources.Get $coverResourcePath -}}
{{- end -}}
{{- end -}}
{{- end -}}
<li>
<a href="{{ $item.RelPermalink }}" title="{{ $item.Title }}">