reindent twitter_cards

This commit is contained in:
Reorx 2022-05-05 11:11:43 +08:00
parent edc5565447
commit 607bfbc544
1 changed files with 27 additions and 26 deletions

View File

@ -1,33 +1,34 @@
{{- if .Params.cover.image -}} {{- if .Params.cover.image -}}
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
{{- if (eq .Params.cover.absolute true) }} {{- if (eq .Params.cover.absolute true) }}
<meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" /> <meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" />
{{- else }}
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
{{- end}}
{{- else }} {{- else }}
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> {{- with $.Params.images -}}
{{- end}} <meta name="twitter:card" content="summary_large_image"/>
{{- else }} <meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
{{- with $.Params.images -}} {{ else -}}
<meta name="twitter:card" content="summary_large_image"/> {{- $images := $.Resources.ByType "image" -}}
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/> {{- $featured := $images.GetMatch "*feature*" -}}
{{ else -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- $images := $.Resources.ByType "image" -}} {{- with $featured -}}
{{- $featured := $images.GetMatch "*feature*" -}} <meta name="twitter:card" content="summary_large_image"/>
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} <meta name="twitter:image" content="{{ $featured.Permalink }}"/>
{{- with $featured -}} {{- else -}}
<meta name="twitter:card" content="summary_large_image"/> {{- with site.Params.images -}}
<meta name="twitter:image" content="{{ $featured.Permalink }}"/> <meta name="twitter:card" content="summary_large_image"/>
{{- else -}} <meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
{{- with site.Params.images -}} {{ else -}}
<meta name="twitter:card" content="summary_large_image"/> <meta name="twitter:card" content="summary"/>
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/> {{- end -}}
{{ else -}} {{- end -}}
<meta name="twitter:card" content="summary"/> {{- end }}
{{- end -}}
{{- end -}}
{{- end }}
{{- end }} {{- end }}
<meta name="twitter:title" content="{{ .Title }}"/> <meta name="twitter:title" content="{{ .Title }}"/>
<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 -}}"/>
{{ with site.Social.twitter -}} {{ with site.Social.twitter -}}
<meta name="twitter:site" content="@{{ . }}"/> <meta name="twitter:site" content="@{{ . }}"/>
{{ end -}} {{ end -}}