When loading a featured image, support global image resources (#326)

This commit is contained in:
Nedjo Rogers 2022-04-12 15:47:08 -07:00
parent c5aec1c5df
commit 65e4aa5269

View File

@ -20,7 +20,17 @@
{{ $matches := "feature,cover" }}
{{/* Use the value from front matter if present */}}
{{ with .Params.featured_image }}
{{/* If we find a remote global Resource matching the exact value, we use it. */}}
{{ if (hasPrefix . "http") }}
{{ with resources.GetRemote . }}
{{ $coverImage = . }}
{{ end }}
{{ else }}
{{/* If we find a local global Resource matching the exact value, we use it. */}}
{{ with resources.Get . }}
{{ $coverImage = . }}
{{ end }}
{{ end }}
{{/* If we find a Page Resource matching the exact value, we use it instead. */}}
{{ with $.Resources.GetMatch . }}
{{ $coverImage = . }}