Résout les images référencées par des métadonnées YAML
This commit is contained in:
@@ -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 }}">
|
||||
|
||||
Reference in New Issue
Block a user