perf(cover): skip global resources lookup when page bundle has the image

The glob over all assets images ran for every list entry and single
page even when the page bundle already matched.
This commit is contained in:
Aditya Telange committed 2026-10-24 17:25:27 +05:30
1 parent 969bebdc56
commit 5f157eba7a
1 file changed
+4 -3
+4 -3
View File
@@ -7,9 +7,10 @@
{{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}
{{- $responsiveImages := (.Params.cover.responsiveImages | default site.Params.cover.responsiveImages) | default true }}
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
{{- $cover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- if not $cover }}
{{- $cover = (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- end }}
{{- /* We are not using the .Param.cover.relative to decide the location of image */}}
{{- /* If we have the image in pageBundle or globalResources we can process the image */}}