Data deep merge not working as expected - any way to achieve it? #1937
Unanswered
andreimoment
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I expect that a data file in the page's folder will override the values defined in a data file in the _data folder.
Given the files described further below,
pre #{JSON.stringify(data)}
in the page should return{"foo":{"a":1,"b":200}}
but instead I get{"foo":{"b":200}}
- basically ifsrc/pages/foo/foo.yaml
exists, nothing fromsrc/ _data/data/foo.yaml
loads.What I am hoping to achieve is a deep merge of data variables from both files so I can define defaults in
_data
and replace only some values in the page data file - or leave them as the default if preferred.How can I achieve something like that?
Here's an example:
I cannot get both yaml files' data to load at the same time. Isn't this something that would work with
eleventyConfig.setDataDeepMerge(true)
?I am using 11ty version 0.12.1
Even if I comment out the contents of
pages/foo/foo.yaml
, the_data/data/foo.yaml
does not load. If I delete thepages/foo/foo.yaml
, then the_data/data/foo.yaml
does load.This is not helpful, because I'm hoping to define default datasets in the _data/data folder and then override them on a page basis, like this:
Beta Was this translation helpful? Give feedback.
All reactions