[PATCH] tpl/tplimpl: Fix deprecation logic in embedded templates

cherry-picked from cb98e9061b
This commit is contained in:
Joe Mooring 2023-11-04 15:08:01 +05:30 committed by Aditya Telange
parent 3fb112bc85
commit 87df659c18
2 changed files with 13 additions and 5 deletions

View File

@ -52,8 +52,10 @@
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}} {{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
{{- $facebookAdmin := "" }} {{- $facebookAdmin := "" }}
{{- with site.Params.social.facebook_admin }} {{- with site.Params.social }}
{{- $facebookAdmin = . }} {{- if reflect.IsMap . }}
{{- $facebookAdmin = .facebook_admin }}
{{- end }}
{{- else }} {{- else }}
{{- with site.Social.facebook_admin }} {{- with site.Social.facebook_admin }}
{{- $facebookAdmin = . }} {{- $facebookAdmin = . }}

View File

@ -30,8 +30,10 @@
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/> <meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} {{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
{{- $twitterSite := "" }} {{- $twitterSite := "" }}
{{- with site.Params.social.twitter }} {{- with site.Params.social }}
{{- $twitterSite = . }} {{- if reflect.IsMap . }}
{{- $twitterSite = .twitter }}
{{- end }}
{{- else }} {{- else }}
{{- with site.Social.twitter }} {{- with site.Social.twitter }}
{{- $twitterSite = . }} {{- $twitterSite = . }}
@ -40,5 +42,9 @@
{{- end }} {{- end }}
{{- with $twitterSite }} {{- with $twitterSite }}
<meta name="twitter:site" content="@{{ . }}"/> {{- $content := . }}
{{- if not (strings.HasPrefix . "@") }}
{{- $content = printf "@%v" $twitterSite }}
{{- end }}
<meta name="twitter:site" content="{{ $content }}"/>
{{- end }} {{- end }}