Skip to content

Commit 87df659

Browse files
jmooringadityatelange
authored andcommitted
[PATCH] tpl/tplimpl: Fix deprecation logic in embedded templates
cherry-picked from gohugoio/hugo@cb98e90
1 parent 3fb112b commit 87df659

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

layouts/partials/templates/opengraph.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252

5353
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
5454
{{- $facebookAdmin := "" }}
55-
{{- with site.Params.social.facebook_admin }}
56-
{{- $facebookAdmin = . }}
55+
{{- with site.Params.social }}
56+
{{- if reflect.IsMap . }}
57+
{{- $facebookAdmin = .facebook_admin }}
58+
{{- end }}
5759
{{- else }}
5860
{{- with site.Social.facebook_admin }}
5961
{{- $facebookAdmin = . }}

layouts/partials/templates/twitter_cards.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
3131
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
3232
{{- $twitterSite := "" }}
33-
{{- with site.Params.social.twitter }}
34-
{{- $twitterSite = . }}
33+
{{- with site.Params.social }}
34+
{{- if reflect.IsMap . }}
35+
{{- $twitterSite = .twitter }}
36+
{{- end }}
3537
{{- else }}
3638
{{- with site.Social.twitter }}
3739
{{- $twitterSite = . }}
@@ -40,5 +42,9 @@
4042
{{- end }}
4143

4244
{{- with $twitterSite }}
43-
<meta name="twitter:site" content="@{{ . }}"/>
45+
{{- $content := . }}
46+
{{- if not (strings.HasPrefix . "@") }}
47+
{{- $content = printf "@%v" $twitterSite }}
48+
{{- end }}
49+
<meta name="twitter:site" content="{{ $content }}"/>
4450
{{- end }}

0 commit comments

Comments
 (0)