mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-12-22 12:13:19 -06:00
30 lines
1008 B
HTML
30 lines
1008 B
HTML
{{ $images := $.Resources.ByType "image" }}
|
|
{{ $featured := $images.GetMatch "*feature*" }}
|
|
{{ if not $featured }}
|
|
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
|
{{ end }}
|
|
|
|
{{ with $featured }}
|
|
{{ $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 }}
|
|
|
|
<meta name="twitter:image" content="{{ $featured.Permalink }}">
|
|
{{ end }}
|
|
|
|
<meta name="twitter:title" content="{{ .Title | plainify }}">
|
|
<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 }}
|