bobatheme/layouts/partials/twitter_cards.html

18 lines
687 B
HTML

{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured }}
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="{{ $featured.Permalink }}">
{{ end }}
<meta name="twitter:title" content="{{ .Title }}">
<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 }}