2021-11-20 18:24:56 -06:00
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured }}
2021-11-20 19:06:18 -06:00
{{ $ratio := 0 }}
{{ if gt .Width .Height }}
{{ $ratio = div (float .Width) .Height }}
{{ else }}
{{ $ratio = div (float .Height) .Width }}
{{ end }}
{{ if lt $ratio 1.75 }}
< meta name = "twitter:card" content = "summary_large_image" >
{{ else }}
< meta name = "twitter:card" content = "summary" >
{{ end }}
2021-11-20 18:24:56 -06:00
< meta name = "twitter:image" content = "{{ $featured.Permalink }}" >
{{ end }}
2021-11-20 19:06:18 -06:00
< meta name = "twitter:title" content = "{{ .Title | plainify }}" >
2021-11-20 18:24:56 -06:00
< meta name = "twitter:description" content = "{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" >
{{ with .Site.Social.twitter }}
< meta name = "twitter:site" content = "@{{ . }}" >
{{ end }}