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

Eleventy computed data consuming collections #1114

Closed
Snugug opened this issue Apr 24, 2020 · 6 comments
Closed

Eleventy computed data consuming collections #1114

Snugug opened this issue Apr 24, 2020 · 6 comments
Labels

Comments

@Snugug
Copy link
Contributor

Snugug commented Apr 24, 2020

Describe the bug
Computed data doesn't seem to work for outputting an object or true (but oddly enough, false works fine). Instead, an error output.split is not a function is thrown

To Reproduce

  1. Create an eleventyComputed.js file in the global data directory.
  2. Export an object with properties.
  3. Have one property use the following: data => true. Note the error output.split is not a function
  4. Change that property to use the following: data => ({}). Note the error output.split is not a function

Expected behavior
Expect to be able to set a computed property to either true or an object.

Environment:

  • Mac OS 10.15.4
  • Node v12.16.1
  • Eleventy 0.11.0-beta.3

Additional context
I expect this to work from the Advanced Details section.

@Snugug Snugug changed the title output.split is not a function Eleventy computed data Eleventy computed data fails with true or object Apr 24, 2020
@zachleat
Copy link
Member

Sorry about this! Some huge changes to computed data have happened recently but a beta hasn’t shipped with those yet. Can you retest with github master before I dive in deeper here?

@Snugug
Copy link
Contributor Author

Snugug commented Apr 24, 2020

My code is in a slightly broken state r/n, but a quick check off of master no longer throws the error I was seeing. I'll be able to check Monday if it's rendering as expected.

Thanks for the quick reply! Love computed data, an excellent addition to 11ty!

@Snugug
Copy link
Contributor Author

Snugug commented Apr 27, 2020

Ok! I've gone ahead and tested this and it is in fact not rendering as expected, although this may be a different issue (and if it is I'm happy to open up a separate issue).

It feels like computed data isn't hooked up to collections yet. Now that objects and true are valid output, I tried to actually build my output; part 1 was grabbing some content from a collection, only to find that the collections object is empty. Step 2 was to see if my computed data was available from a page in a collection, and found that my property wasn't added, and therefore not available, from an element in a collection.

This was all tested in master

@zachleat
Copy link
Member

Thanks for your patience here—can you retest with the latest master?

@zachleat zachleat added this to the Eleventy v0.11.0 milestone Apr 28, 2020
@zachleat zachleat changed the title Eleventy computed data fails with true or object Eleventy computed data consuming collections Apr 28, 2020
@Snugug
Copy link
Contributor Author

Snugug commented Apr 29, 2020

Huzzah! Thank you so much for the work on this! It does appear as if it's working as expected now! 😁

@zachleat
Copy link
Member

Yay! Really appreciate you testing—thanks! I’ll ship a new beta shortly.

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