get-featured-image.html (814B)
1 {{ $images := $.Resources.ByType "image" }} 2 {{ $featured := $images.GetMatch "*feature*" }} 3 {{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end }} 4 {{ if not $featured }} 5 {{ $featured = resources.Get "/opengraph/gohugoio-card-base-1.png" }} 6 {{ $size := 80 }} 7 {{ $title := $.LinkTitle }} 8 {{ if gt (len $title) 20 }} 9 {{ $size = 70 }} 10 {{ end }} 11 12 {{ $text := $title }} 13 {{ $textOptions := dict 14 "color" "#FFF" 15 "size" $size 16 "lineSpacing" 10 17 "x" 65 "y" 80 18 "font" (resources.Get "/opengraph/mulish-black.ttf") 19 }} 20 21 {{ $featured = $featured | images.Filter (images.Text $text $textOptions) }} 22 {{ end }} 23 24 {{ return $featured }}