eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

When a data object references another data object, how to use in 11ty (or nunjucks)?

Open jasonday opened this issue 5 years ago • 0 comments

I have data objects that reference other data objects.

For example:

[
  {
    "_id": "object A id",
    "key1": "value1",
    "linked": [
       {
         "_id": "_object B id"
       }
...

In javascript, I would do something like an ES6 find(), but is there a 11ty-ish way to do this smartly/dynamically? Specifically in templating, if I want key1 from object B, how do I make that reference in nunjucks? Do i need to specify two data sources in my template? What does the nunjucks template tag look like?

jasonday avatar May 11 '20 15:05 jasonday