Résout les images référencées par des métadonnées YAML
This commit is contained in:
@@ -2,18 +2,39 @@
|
||||
{{- $isCoverImage := false -}}
|
||||
{{- $alt := "" -}}
|
||||
{{- with .Params.cover -}}
|
||||
{{- $cover := $.Resources.GetMatch . -}}
|
||||
{{- $cover := false -}}
|
||||
{{- $coverPath := (urls.Parse .).Path -}}
|
||||
{{- if ne $coverPath "" -}}
|
||||
{{- $coverPathLower := lower $coverPath -}}
|
||||
{{- if or (strings.HasSuffix $coverPathLower ".yaml") (strings.HasSuffix $coverPathLower ".yml") -}}
|
||||
{{- $coverDataFile := $.Resources.Get $coverPath -}}
|
||||
{{- if $coverDataFile -}}
|
||||
{{- with $coverDataFile.Content | transform.Unmarshal -}}
|
||||
{{- with index . "file" -}}
|
||||
{{- $coverFilePath := strings.TrimSpace (printf "%v" .) -}}
|
||||
{{- if ne $coverFilePath "" -}}
|
||||
{{- $cover = $.Resources.Get $coverFilePath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $cover = $.Resources.Get $coverPath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if and $cover (ne $cover.MediaType.SubType "svg") -}}
|
||||
{{- $image = $cover -}}
|
||||
{{- $isCoverImage = true -}}
|
||||
{{- $coverName := path.Base . | replaceRE "\\.[^.]+$" "" -}}
|
||||
{{- $coverDataFile := $.Resources.Get (printf "data/images/%s.yaml" $coverName) -}}
|
||||
{{- if not $coverDataFile -}}
|
||||
{{- $coverDataFile = $.Resources.Get (printf "data/%s.yaml" $coverName) -}}
|
||||
{{- $coverDataFile = $.Resources.Get (printf "data/%s.yaml" $coverName) -}}
|
||||
{{- end -}}
|
||||
{{- $coverData := dict -}}
|
||||
{{- if $coverDataFile -}}
|
||||
{{- $coverData = $coverDataFile.Content | transform.Unmarshal -}}
|
||||
{{- with $coverDataFile.Content | transform.Unmarshal -}}
|
||||
{{- $coverData = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $alt = index $coverData "description" | default "" -}}
|
||||
{{- if not $alt -}}
|
||||
|
||||
Reference in New Issue
Block a user