From 3c6d603254737fa2c436662b4dd69e9f824af016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 7 Apr 2024 15:03:50 +0200 Subject: [PATCH] twitter: adjust to Hugo's build-in code #824 --- layouts/partials/twitter_cards.html | 31 ++++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html index 4a33fc6bcb..8f543aa8aa 100644 --- a/layouts/partials/twitter_cards.html +++ b/layouts/partials/twitter_cards.html @@ -1,7 +1,6 @@ -{{- /* based on Hugo 0.119.0 _internal/twitter_cardss.html but with modified title */}} +{{- /* based on Hugo 0.125.0 _internal/twitter_cardss.html but with modified title */}} {{- $format := partial "get-format.hugo" . }} {{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }} -{{- $page := . }} {{- $title := .Title }} {{- if eq $outputFormat "searchpage" }} {{- $title = T "Search" }} @@ -15,31 +14,17 @@ {{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }} {{- end }} -{{- with $.Params.images }} + +{{- $images := partial "_funcs/get-page-images" . }} +{{- with index $images 0 }} - + {{- 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 }} -{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} {{- $twitterSite := "" }} {{- with site.Params.social.twitter }} {{- $twitterSite = . }} @@ -54,5 +39,9 @@ {{- end }} {{- with $twitterSite }} - + {{- $content := . }} + {{- if not (strings.HasPrefix . "@") }} + {{- $content = printf "@%v" . }} + {{- end }} + {{- end }} \ No newline at end of file