{{- $image := false -}} {{- $isCoverImage := false -}} {{- $alt := "" -}} {{- with .Params.cover -}} {{- $cover := $.Resources.GetMatch . -}} {{- 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) -}} {{- end -}} {{- $coverData := dict -}} {{- if $coverDataFile -}} {{- $coverData = $coverDataFile.Content | transform.Unmarshal -}} {{- end -}} {{- $alt = index $coverData "description" | default "" -}} {{- if not $alt -}} {{- $alt = index $coverData "title" | default "" -}} {{- end -}} {{- end -}} {{- end -}} {{- if not $image -}} {{- $logoPath := site.Params.logo | default "logo-large.png" -}} {{- $logo := resources.GetMatch $logoPath -}} {{- if and $logo (ne $logo.MediaType.SubType "svg") -}} {{- $image = $logo -}} {{- end -}} {{- end -}} {{- if not $alt -}} {{- if and $image $isCoverImage -}} {{- if and .IsPage (not .IsHome) -}} {{- $alt = printf "Image de partage pour %s" .Title -}} {{- else -}} {{- $alt = printf "Logo du site %s" site.Title -}} {{- end -}} {{- else if $image -}} {{- $alt = printf "Logo du site %s" site.Title -}} {{- end -}} {{- end -}} {{- $data := dict -}} {{- if $image -}} {{- $isInterestingLink := and $isCoverImage (strings.HasPrefix .RelPermalink "/interets/liens-interessants/") -}} {{- $shouldBlur := $isInterestingLink -}} {{- $cropAnchor := "Center" -}} {{- if $isInterestingLink -}} {{- $cropAnchor = "Top" -}} {{- end -}} {{- $alt = $alt | strings.TrimSpace | truncate 420 -}} {{- $data = dict "openGraph" (partial "head/social-image-variant.html" (dict "image" $image "width" 1200 "height" 630 "anchor" $cropAnchor "alt" $alt "blur" $shouldBlur )) "twitter" (partial "head/social-image-variant.html" (dict "image" $image "width" 1200 "height" 1200 "anchor" $cropAnchor "alt" $alt "blur" $shouldBlur )) -}} {{- end -}} {{- return $data -}}