Suppose you specify an item in a directory data file with `eleventyComputed, e.g. in *.11tydata.js you have

module.exports = {
    eleventyComputed: {
        myItem: {
            foo: "defaultFoo",
            bar: "defaultBar"
        }
    }
};

and you want to override that item in a template file. You must use eleventyComputed there, as well. So,

---
myItem:
    foo: newFooValue
    bar: newBarValue
title: Post 2
---

does not work. But

---
eleventyComputed:
    myItem:
        foo: newFooValue
        bar: newBarValue
title: Post 3
---

Maybe that should be documented as a common pitfall. It took me quite a bit to figure out what I was doing wrong.

0
© 2022 pullanswer.com - All rights reserved.