From 97af798ba1ff24a6eccf4b48e3cdfd2e89236a91 Mon Sep 17 00:00:00 2001 From: Reorx Date: Thu, 5 May 2022 11:24:13 +0800 Subject: [PATCH] simpler twitter cards --- layouts/partials/head.html | 21 ++++++++---- layouts/partials/templates/twitter_cards.html | 34 ------------------- 2 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 layouts/partials/templates/twitter_cards.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 3dfd3a4..3411f18 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -57,12 +57,6 @@ {{- /* Favicons */}} - - - - - - {{- /* RSS */}} {{ range .AlternativeOutputFormats -}} @@ -76,8 +70,21 @@ {{- if hugo.IsProduction | or (eq site.Params.env "production") }} {{- template "_internal/google_analytics.html" . }} {{- end -}} + +{{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}} +{{- if .Params.cover.image }} + + + + + + +{{- else -}} + {{- template "_internal/twitter_cards.html" . -}} +{{- end -}} + {{- template "partials/templates/opengraph.html" . }} -{{- template "partials/templates/twitter_cards.html" . }} + {{- template "partials/templates/schema_json.html" . }} {{- partial "extend_head.html" . }} diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html deleted file mode 100644 index bc744b2..0000000 --- a/layouts/partials/templates/twitter_cards.html +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Params.cover.image -}} - - {{- if (eq .Params.cover.absolute true) }} - - {{- else }} - - {{- end}} -{{- else }} - {{- with $.Params.images -}} - - - {{ else -}} - {{- $images := $.Resources.ByType "image" -}} - {{- $featured := $images.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{- with $featured -}} - - - {{- else -}} - {{- with site.Params.images -}} - - - {{ else -}} - - {{- end -}} - {{- end -}} - {{- end }} -{{- end }} - - - -{{ with site.Social.twitter -}} - -{{ end -}}