mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-11-17 13:25:57 -06:00
Select summary or summary_large_image in twitter card with image size
This commit is contained in:
parent
a01a70fc91
commit
d9776d29c4
@ -5,11 +5,23 @@
|
||||
{{ end }}
|
||||
|
||||
{{ with $featured }}
|
||||
<meta name="twitter:card" content="summary">
|
||||
{{ $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 }}">
|
||||
<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 }}
|
||||
|
Loading…
Reference in New Issue
Block a user