51 lines
1.9 KiB
HTML
51 lines
1.9 KiB
HTML
<!-- 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" }}
|
|
|
|
<meta itemprop="name" content="{{ .Title }}">
|
|
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
|
{{- if .IsPage -}}
|
|
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
|
{{ with .PublishDate }}<meta itemprop="datePublished" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
|
{{ with .Lastmod }}<meta itemprop="dateModified" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
|
<meta itemprop="wordCount" content="{{ .WordCount }}">
|
|
<meta itemprop="image" content="{{ $card.Permalink | absURL }}"/>
|
|
<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />
|
|
{{- end -}}
|