{{- /* Only raster formats X can render; SVG cards are rejected. WebP is converted rather than skipped. Matches head/opengraph.html. */ -}} {{- $twFormats := slice "png" "jpeg" -}} {{- $twImage := "" -}} {{- range $.Params.images -}} {{- if not $twImage -}} {{- with $.Resources.GetMatch . -}} {{- if in $twFormats .MediaType.SubType -}} {{- $twImage = (.Resize "960x").Permalink -}} {{- else if eq .MediaType.SubType "webp" -}} {{- $twImage = (.Resize "960x jpeg q85").Permalink -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- if not $twImage -}} {{- range $.Site.Params.images -}} {{- if not $twImage -}} {{- with resources.GetMatch . -}} {{- if in $twFormats .MediaType.SubType -}} {{- $twImage = (.Resize "960x").Permalink -}} {{- else if eq .MediaType.SubType "webp" -}} {{- $twImage = (.Resize "960x jpeg q85").Permalink -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end }} {{ if $twImage }} {{- else }} {{- end }} {{/* params.twitterSite is the documented setting. params.social.twitter stays as a fallback for sites configured before it existed; that param is also a plausible name for a list of [[params.social]] links, and indexing a slice by field name is a build error, so its shape is checked rather than assumed. */}} {{- $handle := site.Params.twitterSite -}} {{- if and (not $handle) (reflect.IsMap site.Params.social) -}} {{- $handle = site.Params.social.twitter -}} {{- end }} {{ with $handle -}} {{ end -}}