mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38'
This commit is contained in:
26
docs/layouts/_partials/opengraph/get-featured-image.html
Normal file
26
docs/layouts/_partials/opengraph/get-featured-image.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{ $images := $.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ if not $featured }}
|
||||
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||
{{ end }}
|
||||
{{ if not $featured }}
|
||||
{{ $featured = resources.Get "/opengraph/gohugoio-card-base-1.png" }}
|
||||
{{ $size := 80 }}
|
||||
{{ $title := $.LinkTitle }}
|
||||
{{ if gt (len $title) 20 }}
|
||||
{{ $size = 70 }}
|
||||
{{ end }}
|
||||
|
||||
{{ $text := $title }}
|
||||
{{ $textOptions := dict
|
||||
"color" "#FFF"
|
||||
"size" $size
|
||||
"lineSpacing" 10
|
||||
"x" 65 "y" 80
|
||||
"font" (resources.Get "/opengraph/mulish-black.ttf")
|
||||
}}
|
||||
|
||||
{{ $featured = $featured | images.Filter (images.Text $text $textOptions) }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $featured }}
|
Reference in New Issue
Block a user