Reputation: 31
A page on my site calls .Resources.Match
to fetch a group of content files that I expect to have their own .Resources
property, but do not. I would like to fetch the page, then get a resource. The content structure is like a page bundle, and I've added [[resources]]
to the front matter, but neither .BundleType
nor Resources
is set (.Resources
returns an empty array). How can I get the content, then the resource?
page/
├─ index.md
└- leaf_bundles/
└- leaf/
├─ index.md
└─ resource.etc
page/index.md
{{ $leaf := .Resources.Match "leaf_bindles/**/*.md" | index 0 }}
{{ $leaf.IsPage }} // => true
{{ $leaf.Resources }} // => []
leaf/index.md
[[resources]]
name = "resource"
src = "resource.etc"
I assume that if I were to create a template for "leaf", .Resources
would be populated in that context. Is it possible to fetch leaf bundle resources from a page returned itself by a call to .Match?
Upvotes: 0
Views: 715
Reputation: 31
I was able to achieve the desired result -- accessing page bundle content and resources from a parent page -- using .Pages
and the where
operator. Instead of calling .Resources.Match
to fetch the .md
file of a page bundle, .Pages where "Type" "mySection"
returns the page bundle in its entirety, including a pointer to its resources. I set the "type" in front matter, and am good to go.
Thanks to misterbisson whose post led to my solution.
Upvotes: 1