1

Images sociales

This commit is contained in:
2026-03-14 21:27:49 +01:00
parent 32fdcc201f
commit 7676fe3e22
3 changed files with 86 additions and 14 deletions

View File

@@ -39,17 +39,33 @@
{{- $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
"url" $image.Permalink
"alt" ($alt | strings.TrimSpace | truncate 420)
"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
))
-}}
{{- with $image.Width -}}
{{- $data = merge $data (dict "width" .) -}}
{{- end -}}
{{- with $image.Height -}}
{{- $data = merge $data (dict "height" .) -}}
{{- end -}}
{{- end -}}
{{- return $data -}}