feat: use data from custom collections when using prototypes
Summary
Hey!
I'm loading all the data from external API, so everything lives under my site.collections hash. When using a prototype, I'm trying to pull some labels from the collection to use it as the page title, with the :prototype-data-label variable, but it fails.
Guide-level explanation
When using prototypes, you can declare two arguments in the Front Matter segment, like this:
---
layout: default
title: Articles by :prototype-data-label
prototype:
term: author
data: authors
data_label: name
---
However, the prototype generator will only look for that label at the site.data hash, for example: site.data[:authors][term][:name].
If you loaded the data from an external API, this data will be accessable at the site.collections hash, not at the site.data one.
Reference-level explanation
I reckon we could add something here so if we don't find anything at site.data, we can try at the site's collections before returning.
Drawbacks
I don't see any drawbacks, to be honest.
Unresolved Questions
No questions so far.
Makes sense…we could probably leverage the Relations API here so that the prototype page would pull in the join data through a named relation.