Résout les images référencées par des métadonnées YAML
This commit is contained in:
@@ -3,15 +3,23 @@
|
||||
{{- $coverPath := .Params.cover -}}
|
||||
{{- $img := false -}}
|
||||
{{- if $coverPath -}}
|
||||
{{- if strings.HasSuffix $coverPath ".yaml" -}}
|
||||
{{- $coverAbsPath := printf "%s%s" $page.File.Dir $coverPath -}}
|
||||
{{- $coverRaw := readFile $coverAbsPath -}}
|
||||
{{- $coverData := $coverRaw | transform.Unmarshal -}}
|
||||
{{- with $coverData.file -}}
|
||||
{{- $img = $page.Resources.GetMatch . -}}
|
||||
{{- $coverResourcePath := (urls.Parse $coverPath).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 "" -}}
|
||||
{{- $img = $page.Resources.Get $coverFilePath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $img = $page.Resources.GetMatch $coverPath -}}
|
||||
{{- $img = $page.Resources.Get $coverResourcePath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $img -}}
|
||||
|
||||
Reference in New Issue
Block a user