twitter: add twitter cards

This commit is contained in:
Marcin Mierzejewski 2020-05-03 13:51:54 +02:00
parent 512902121b
commit 3184aed8b5
2 changed files with 20 additions and 1 deletions

View file

@ -23,7 +23,7 @@
{{ printf `<link href="%s" rel="%s" type="%s" title="%s" />` .Permalink .Rel .MediaType.Type $.Site.Title | safeHTML }}
{{ end }}
{{- partial "opengraph.html" . -}}
{{ template "_internal/twitter_cards.html" . }}
{{- partial "twitter_cards.html" . -}}
{{ template "_internal/google_analytics.html" . }}
</head>
<body class="terminal">

View file

@ -0,0 +1,19 @@
{{- with .Params.image }}
{{ $image := $.Resources.GetMatch . }}
{{ with $image }}
{{ $thumb := .Resize "400x" }}
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="{{ $thumb.Permalink }}">
{{ end }}
{{ end }}
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
{{ with .Site.Social.twitter -}}
<meta name="twitter:site" content="@{{ . }}"/>
{{ end -}}
{{ range .Site.Authors }}
{{ with .twitter -}}
<meta name="twitter:creator" content="@{{ . }}"/>
{{ end -}}
{{ end -}}