aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials/social_card.html
blob: 520162cd38033a1e3c18fd36ba211e0a4d036ab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!-- Dynamic social card generation -->
{{ $font := resources.Get "fonts/FiraMono-Bold.ttf" }}
{{ $fg := resources.Get "images/social_card_fg.png"}}
{{ $bg := resources.Get "images/social_card_bg.png"}}

{{ if gt (len .Title) 40 }}
  {{ $fg = $fg.Filter (images.Text .Title (dict
    "font" $font
    "color" "#fafafa"
    "size" 95
    "linespacing" 16
    "x" 0
    "y" 0
  )) }}
{{ else }}
  {{ $fg = $fg.Filter (images.Text .Title (dict
    "font" $font
    "color" "#fafafa"
    "size" 130
    "linespacing" 20
    "x" 0
    "y" 0
  )) }}
{{ end }}

{{ $date := .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
{{ $author := (default $.Site.Params.author.name ($.Param "author.name")) }}
{{ $byline := (printf "%s | %s" $author $date) }}

{{ $fg = $fg.Filter (images.Text $byline (dict
    "font" $font
    "color" "#898a8d"
    "size" 60
    "linespacing" 30
    "x" 0
    "y" 425
)) }}

{{ $card := $bg.Filter (images.Overlay $fg 112 140 ) }}
{{ $card := $card.Resize "900x webp q100" }}