Skip to content

overriding eleventyComputed #2574

Open
Open
@btrem

Description

@btrem

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions