Hi S,
There is a feature in Nanoc that’s still behind a feature flag that might help you here: the #where method on collections. Like #select, it can be used to find items by attribute, like this:
@items.where(kind: 'article')
@items.where(kind: 'article', year: 2020)
You’ll need to set the environment variable NANOC_FEATURES to where, e.g.
export NANOC_FEATURES=where
The primary advantage to using #where over #select is that it generates only very specific dependencies. As a result, you’ll find that Nanoc will recompile fewer pages.
If you combine this with a preprocess block that sets the item types, then you’d be able to efficiently find individual wrestlers, like this:
# in Rules
preprocess do
@items.find_all('/wrestlers/*.md').each do |w|
w[:kind] = 'wrestler'
end
end
# elsewhere
@items.find(kind: 'wrestler', slug: 'abc')
I’m not certain that this fits the structure of the data in your site as you have it right now. Let me know what you think!
Denis Defreyne
[dəˈni] • pronouns: he/him