Description
Description
The 11ty docs on opting out of data merging mention that you can use an override:
prefix to opt out of merging data for a specific front-matter variable:
Use the override: prefix on any data key to opt-out of this merge behavior for specific values or nested values.
{
"tags": ["posts"]
}
---
override:tags: []
---
Even though normally the posts/firstpost.md file would inherit the posts tag from the directory data file (per normal data cascade rules), we can override the tags value to be an empty array to opt-out of this behavior.
But how would I opt out of deep data merging for data files? For example, suppose I have this file: src/_data/data.js
:
// src/_data/data.js
module.exports = {
key: "value",
}
And later, somewhere in a directory, I want to override this data file:
// src/_collection/collection.11tydata.js
module.exports = {
"override:data": {
key: "new-value"
}
}
Unfortunately, this doesn't work. Is this not supported, or do I need to use a different syntax?
Steps to repro
- Clone https://github.com/AleksandrHovhannisyan/11ty-sandbox/tree/merge-override
- Run
yarn
to install dependencies. - Run
yarn serve
. - Observe that
{ "key1": "value1", "key2": "value2" }
is logged in the server console. - Expectation: Only
{ "key2": "value2" }
gets logged.