107 lines
4.0 KiB
HTML
107 lines
4.0 KiB
HTML
{{- $imgPath := (urls.Parse .Destination).Path -}}
|
|
{{- $imgName := path.Base $imgPath | replaceRE "\\.[^.]+$" "" -}}
|
|
{{- $dataPath := printf "data/images/%s.yaml" $imgName -}}
|
|
{{- $dataFile := .Page.Resources.Get $dataPath -}}
|
|
{{- $data := dict -}}
|
|
{{- if $dataFile -}}
|
|
{{- with $dataFile.Content | transform.Unmarshal -}}
|
|
{{- $data = . -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $alt := .PlainText | default $data.title | default "" -}}
|
|
{{- $title := .Title | default $data.title | default .Page.Title -}}
|
|
{{- $description := $data.description | default "" -}}
|
|
{{- $image := false -}}
|
|
{{- $imagePathLower := lower $imgPath -}}
|
|
{{- if or (strings.HasSuffix $imagePathLower ".yaml") (strings.HasSuffix $imagePathLower ".yml") -}}
|
|
{{- $imageDataFile := .Page.Resources.Get $imgPath -}}
|
|
{{- if $imageDataFile -}}
|
|
{{- with $imageDataFile.Content | transform.Unmarshal -}}
|
|
{{- with index . "file" -}}
|
|
{{- $imageFilePath := strings.TrimSpace (printf "%v" .) -}}
|
|
{{- if ne $imageFilePath "" -}}
|
|
{{- $image = $.Page.Resources.Get $imageFilePath -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- $image = .Page.Resources.Get $imgPath -}}
|
|
{{- end -}}
|
|
{{- with $image -}}
|
|
{{- $resolvedImage := . -}}
|
|
{{- $metaTitle := index $data "title" -}}
|
|
{{- $hasMeta := or $metaTitle (or $description (or $data.attribution $data.prompt)) -}}
|
|
{{- $attributes := $.Attributes | default dict -}}
|
|
{{- $imageClasses := "" -}}
|
|
{{- with index $attributes "class" -}}
|
|
{{- $imageClasses = lower (trim . " ") -}}
|
|
{{- end -}}
|
|
{{- $layout := "" -}}
|
|
{{- with index $attributes "layout" -}}
|
|
{{- $layout = lower (trim . " ") -}}
|
|
{{- end -}}
|
|
{{- $hasCenterClass := gt (len (findRE `(^|\\s)(center|centered)(\\s|$)` $imageClasses)) 0 -}}
|
|
{{- $hasFullClass := gt (len (findRE `(^|\\s)(full|full-width|wide)(\\s|$)` $imageClasses)) 0 -}}
|
|
{{- $forceCentered := false -}}
|
|
{{- if or (in (slice "center" "centered") $layout) $hasCenterClass -}}
|
|
{{- $forceCentered = true -}}
|
|
{{- end -}}
|
|
{{- if or (in (slice "full" "full-width" "wide") $layout) $hasFullClass -}}
|
|
{{- $forceCentered = true -}}
|
|
{{- end -}}
|
|
{{- $forceWithoutMeta := false -}}
|
|
{{- if or (in (slice "full" "full-width" "wide") $layout) $hasFullClass -}}
|
|
{{- $forceWithoutMeta = true -}}
|
|
{{- end -}}
|
|
{{- $showMeta := and $hasMeta (not $forceWithoutMeta) -}}
|
|
{{- $figureClasses := slice "figure-media" -}}
|
|
{{- if $showMeta -}}
|
|
{{- $figureClasses = $figureClasses | append "figure-media-with-meta" -}}
|
|
{{- else -}}
|
|
{{- $figureClasses = $figureClasses | append "figure-media-without-meta" -}}
|
|
{{- end -}}
|
|
{{- if $forceCentered -}}
|
|
{{- $figureClasses = $figureClasses | append "figure-media-centered" -}}
|
|
{{- end -}}
|
|
{{- with $imageClasses -}}
|
|
{{- $figureClasses = $figureClasses | append . -}}
|
|
{{- end -}}
|
|
<figure class="{{ delimit $figureClasses " " }}">
|
|
<a href="{{ $resolvedImage.RelPermalink }}" title="Cliquez pour agrandir l'image">
|
|
{{- partial "media/display-img.html" (dict
|
|
"image" $resolvedImage
|
|
"showMeta" $showMeta
|
|
"forceCentered" $forceCentered
|
|
"alt" $alt
|
|
"title" $title
|
|
) -}}
|
|
</a>
|
|
{{- if $showMeta -}}
|
|
<figcaption class="figure-media-meta cover-meta">
|
|
<div class="figure-media-meta-main">
|
|
{{- with $metaTitle -}}
|
|
<p class="figure-title cover-title">{{ . | markdownify }}</p>
|
|
{{- end -}}
|
|
{{- with $description -}}
|
|
<p class="figure-description cover-description">{{ . | markdownify }}</p>
|
|
{{- end -}}
|
|
</div>
|
|
{{- if or $data.attribution $data.prompt -}}
|
|
<div class="figure-media-meta-extra">
|
|
{{- with $data.attribution -}}
|
|
<p class="figure-attribution cover-attribution"><strong>Attribution :</strong> <span>{{ . | markdownify }}</span></p>
|
|
{{- end -}}
|
|
{{- with $data.prompt -}}
|
|
<details>
|
|
<summary>Prompt</summary>
|
|
<p>{{ . | markdownify }}</p>
|
|
</details>
|
|
{{- end -}}
|
|
</div>
|
|
{{- end -}}
|
|
</figcaption>
|
|
{{- end -}}
|
|
</figure>
|
|
{{- end -}}
|