From 87df659c185b91ab09f8eb978b3aab5945b0f8b5 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 4 Nov 2023 15:08:01 +0530 Subject: [PATCH] [PATCH] tpl/tplimpl: Fix deprecation logic in embedded templates cherry-picked from https://github.com/gohugoio/hugo/commit/cb98e9061b3d62b6f1e635a6cf9a8be57dc3f56c --- layouts/partials/templates/opengraph.html | 6 ++++-- layouts/partials/templates/twitter_cards.html | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html index b7fe84c7..38fbd246 100644 --- a/layouts/partials/templates/opengraph.html +++ b/layouts/partials/templates/opengraph.html @@ -52,8 +52,10 @@ {{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}} {{- $facebookAdmin := "" }} -{{- with site.Params.social.facebook_admin }} - {{- $facebookAdmin = . }} +{{- with site.Params.social }} + {{- if reflect.IsMap . }} + {{- $facebookAdmin = .facebook_admin }} + {{- end }} {{- else }} {{- with site.Social.facebook_admin }} {{- $facebookAdmin = . }} diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html index bdb59239..0e7760aa 100644 --- a/layouts/partials/templates/twitter_cards.html +++ b/layouts/partials/templates/twitter_cards.html @@ -30,8 +30,10 @@ {{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} {{- $twitterSite := "" }} -{{- with site.Params.social.twitter }} - {{- $twitterSite = . }} +{{- with site.Params.social }} + {{- if reflect.IsMap . }} + {{- $twitterSite = .twitter }} + {{- end }} {{- else }} {{- with site.Social.twitter }} {{- $twitterSite = . }} @@ -40,5 +42,9 @@ {{- end }} {{- with $twitterSite }} - + {{- $content := . }} + {{- if not (strings.HasPrefix . "@") }} + {{- $content = printf "@%v" $twitterSite }} + {{- end }} + {{- end }}