Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global computed data overrides global data set in consuming app #346

Closed
lhokktyn opened this issue Oct 14, 2024 · 0 comments · Fixed by #347
Closed

Global computed data overrides global data set in consuming app #346

lhokktyn opened this issue Oct 14, 2024 · 0 comments · Fixed by #347

Comments

@lhokktyn
Copy link
Contributor

The global data applied for eleventyComputed here ...

eleventyConfig.addGlobalData(
  'eleventyComputed',
  require('./lib/data/eleventy-computed.js')
)

... overrides any data that I set in my consuming app, e.g.

eleventyConfig.addGloblData('eleventyComputed.myGlobalVar', () => (data) => "abc");

I would expect the above to result in;

eleventyComputed: {
  eleventyNavigation: {
    key: (data) => getKey(data),
    parent: (data) => getParent(data),
    excerpt: (data) => data.eleventyNavigation.excerpt || data.description
  },
  myGlobalVar: (data) => "abc",
}

But myGlobalVar is actually not present.

I believe this is a result of the issue described here.

Hacking a change into /main/index.js fixes the issue:

eleventyConfig.addGlobalData(
  'eleventyComputed.eleventyNavigation',
  require('./lib/data/eleventy-computed.js').eleventyNavigation
)

I'll look at submitting a PR for this.

lhokktyn added a commit to lhokktyn/govuk-eleventy-plugin that referenced this issue Oct 14, 2024
paulrobertlloyd pushed a commit that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant