Résout les images référencées par des métadonnées YAML
This commit is contained in:
@@ -17,9 +17,10 @@
|
||||
{{- if or (strings.HasSuffix $coverPathLower ".yaml") (strings.HasSuffix $coverPathLower ".yml") -}}
|
||||
{{- $coverDataFile := $page.Resources.GetMatch $coverPath -}}
|
||||
{{- if $coverDataFile -}}
|
||||
{{- $coverData := $coverDataFile.Content | transform.Unmarshal -}}
|
||||
{{- with index $coverData "file" -}}
|
||||
{{- $coverImagePath = strings.TrimSpace (printf "%v" .) -}}
|
||||
{{- with $coverDataFile.Content | transform.Unmarshal -}}
|
||||
{{- with index . "file" -}}
|
||||
{{- $coverImagePath = strings.TrimSpace (printf "%v" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
@@ -28,7 +29,8 @@
|
||||
{{- end -}}
|
||||
{{- $coverImageName := "" -}}
|
||||
{{- if ne $coverImagePath "" -}}
|
||||
{{- $coverImageName = lower (path.Base $coverImagePath) -}}
|
||||
{{- $coverImageName = lower (path.Base ((urls.Parse $coverImagePath).Path)) -}}
|
||||
{{- $coverImageName = replace $coverImageName "%20" " " -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $contentImageNames := slice -}}
|
||||
@@ -37,9 +39,12 @@
|
||||
{{- range $imageTags -}}
|
||||
{{- $srcMatch := findRESubmatch `(?is)src=["']([^"']+)["']` . -}}
|
||||
{{- if gt (len $srcMatch) 0 -}}
|
||||
{{- $src := lower (index (index $srcMatch 0) 1) -}}
|
||||
{{- $srcRaw := index (index $srcMatch 0) 1 -}}
|
||||
{{- $srcPath := (urls.Parse $srcRaw).Path -}}
|
||||
{{- $src := lower $srcPath -}}
|
||||
{{- if or (in $src "/images/") (strings.HasPrefix $src "images/") (strings.HasPrefix $src "./images/") -}}
|
||||
{{- $srcName := path.Base $src -}}
|
||||
{{- $srcName := lower (path.Base $srcPath) -}}
|
||||
{{- $srcName = replace $srcName "%20" " " -}}
|
||||
{{- $srcName = replaceRE "\\?.*$" "" $srcName -}}
|
||||
{{- $srcName = replaceRE "#.*$" "" $srcName -}}
|
||||
{{- $srcName = replaceRE "_hu_[^.]*" "" $srcName -}}
|
||||
@@ -95,7 +100,9 @@
|
||||
{{- $dataFile = $page.Resources.Get (printf "data/%s.yaml" $imageStem) -}}
|
||||
{{- end -}}
|
||||
{{- if $dataFile -}}
|
||||
{{- $data = $dataFile.Content | transform.Unmarshal -}}
|
||||
{{- with $dataFile.Content | transform.Unmarshal -}}
|
||||
{{- $data = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}}
|
||||
{{- $thumbnail := . -}}
|
||||
|
||||
Reference in New Issue
Block a user