{{- /*
  Resolve a page's featured image to a Resource.
  Looks at the `featured` front-matter key first, then falls back to the first
  image in the page bundle.
  Returns the Resource, or nothing.
*/ -}}
{{- $img := "" -}}
{{- with .Resources.GetMatch (printf "%s" (.Params.featured | default "")) -}}
  {{- $img = . -}}
{{- else -}}
  {{- with .Resources.ByType "image" -}}
    {{- $img = index . 0 -}}
  {{- end -}}
{{- end -}}
{{- return $img -}}
