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

Can’t find properties of global data via eleventyComputed #1043

Closed
paulrobertlloyd opened this issue Mar 25, 2020 · 1 comment
Closed

Can’t find properties of global data via eleventyComputed #1043

paulrobertlloyd opened this issue Mar 25, 2020 · 1 comment
Labels

Comments

@paulrobertlloyd
Copy link
Contributor

I’m looking at the new computed data feature, and seems like it can help me greatly simplify my templates (and perhaps help improve build time as a result). However, I’ve come across an issue.


Given the following *.11tydata.js file in a directory:

module.exports = {
  layout: 'article',
  permalink: '{{ page.date | date: "%Y/%m" }}/{{ page.fileSlug }}.html',
  eleventyComputed: {
    image: data => {
      console.log(data.app); // data.app is populated by the global data file, app.js
    }
  }
};

Logging data.app, I get the following output (simplified) in the console for each page in the directory:

{
  title: 'Paul Robert Lloyd',
  short_title: 'PRL',
  description: 'The personal website of Paul Robert Lloyd'
}

However, if I update my *.11tydata.js file to log data.app.title, I get the following error:

Problem writing Eleventy templates: (more in DEBUG output)
> Cannot read property 'title' of undefined

This is weird, as that was previously shown as a property of app. Have I missed something?

@zachleat zachleat added this to the Eleventy v0.11.0 milestone Mar 26, 2020
@zachleat zachleat added bug and removed education labels Apr 1, 2020
@zachleat
Copy link
Member

zachleat commented Apr 1, 2020

Related to/fixed with #1061.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants