diff options
author | Thomas T <jjtaylor1925@gmail.com> | 2021-12-26 12:40:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 12:40:13 +0300 |
commit | c52acfb01bb0188da4f76b1378d9045041772a99 (patch) | |
tree | b68ca62c7f22bdc281f42c6d51f6a16c011b8c43 | |
parent | 4c10fbdc197202bd907ebeba8a25bceeac3f54ee (diff) |
feat: Twitter card support (#64)
* feat: add `_internal/twitter_cards.html` template support
* use `with $.Params.images` logic directly
-rw-r--r-- | layouts/partials/head/head.html | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html index 7c3c570..76d91fb 100644 --- a/layouts/partials/head/head.html +++ b/layouts/partials/head/head.html @@ -15,6 +15,25 @@ <meta name="twitter:title" content="{{with.Title}}{{.}} | {{end}}{{.Site.Title}}" /> <meta name="application-name" content="{{with.Title}}{{.}} | {{end}}{{.Site.Title}}" /> + {{- with $.Params.images -}} + <meta name="twitter:card" content="summary_large_image"/> + <meta name="twitter:image" content="{{ index . 0 | absURL }}"/> + {{ 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 }}"/> + {{- else -}} + {{- with $.Site.Params.images -}} + <meta name="twitter:card" content="summary_large_image"/> + <meta name="twitter:image" content="{{ index . 0 | absURL }}"/> + {{ else -}} + <meta name="twitter:card" content="summary"/> + {{- end -}} + {{- end -}} + {{- end }} <meta name="description" content="{{ if .Description }}{{.Description}}{{ else }}{{.Site.Params.siteDesc}}{{end}}" /> <meta name="twitter:description" content="{{ if .Description }}{{.Description}} {{ else }}{{.Site.Params.siteDesc}}{{end}}"/> |