Changes .GetMatch Pattern to find bundled assets

When I attempted to use `func/GetFeaturedImage.html`, it did not find my resource, `images/foo-cover.webp`. Updating the match syntax to the pattern expressed here, provided expected behavior:

Per:

https://gohugo.io/content-management/page-resources/#pattern-matching

> .Resources.Match "*sunset.jpg" 🚫

and...

> .Resources.Match "*" 🚫

Are not expected to work

> .Resources.Match "**/sunset.jpg" 

which follows this change, does.
This commit is contained in:
Steven G. Harms 2021-03-29 07:05:57 -04:00
parent 8845854aa9
commit 0f40733d46

View File

@ -24,7 +24,7 @@
{{/* Find the first image with 'cover' in the name in this page bundle. */}} {{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }} {{ else }}
{{ $img := (.Resources.ByType "image").GetMatch "*cover*" }} {{ $img := (.Resources.ByType "image").GetMatch "**/*cover*" }}
{{ with $img }} {{ with $img }}
{{ $linkToCover = .Permalink }} {{ $linkToCover = .Permalink }}
{{ end }} {{ end }}