website-theme/layouts/partials/external/twitter_cards.html

32 lines
1.4 KiB
HTML
Raw Permalink Normal View History

2020-02-26 06:00:39 -05:00
<!-- https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html -->
{{- with $.Params.images -}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="{{ index . 0 | absURL }}">
2020-02-26 06:00:39 -05:00
{{ else -}}
{{- $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_large_image">
<meta name="twitter:image" content="{{ $featured.Permalink }}">
2020-02-26 06:00:39 -05:00
{{- else -}}
{{- with $.Site.Params.images -}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="{{ index . 0 | absURL }}">
2020-02-26 06:00:39 -05:00
{{ else -}}
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="{{ .Site.BaseURL }}img/{{ .Site.Params.avatar }}">
2020-02-26 06:00:39 -05:00
{{- end -}}
{{- 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 -}}">
2020-02-26 06:00:39 -05:00
{{ with .Site.Social.twitter -}}
<meta name="twitter:site" content="@{{ . }}">
2020-02-26 06:00:39 -05:00
{{ end -}}
{{ range .Site.Authors }}
{{ with .twitter -}}
<meta name="twitter:creator" content="@{{ . }}">
2020-02-26 06:00:39 -05:00
{{ end -}}
{{ end -}}