Skip to content

Commit

Permalink
tpl/tplimpl: Fix deprecation logic in embedded templates
Browse files Browse the repository at this point in the history
Closes #11658
  • Loading branch information
jmooring authored and bep committed Nov 1, 2023
1 parent 5fa97ee commit cb98e90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tpl/tplimpl/embedded/templates/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,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 = . }}
Expand Down
12 changes: 9 additions & 3 deletions tpl/tplimpl/embedded/templates/twitter_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,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 = . }}
Expand All @@ -32,5 +34,9 @@
{{- end }}

{{- with $twitterSite }}
<meta name="twitter:site" content="@{{ . }}"/>
{{- $content := . }}
{{- if not (strings.HasPrefix . "@") }}
{{- $content = printf "@%v" $twitterSite }}
{{- end }}
<meta name="twitter:site" content="{{ $content }}"/>
{{- end }}

0 comments on commit cb98e90

Please sign in to comment.