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
Support passing information to JavaScript data files #795
Comments
|
Sounds like you're hoping to access In a class-based It may be available to an exported function Seems like there was another issue posted recently about modifying data before rendering a template, |
|
Related #642 |
|
Um... am I crazy or is data/render not documented anywhere? I don't see it here - https://www.11ty.dev/docs/data-js/. How is this featured used? |
Aw man, I'm the crazy one, sorry. I was thinking JavaScript template files (11ty.js). |
|
No worries - thank you for trying to help! |
|
This should probably be possible in v0.11 thanks to the new |
|
Well it was possible before by workarounds. This does not feel like a solution to the original ask though. I want to use this data in my data file, before a template even tries to use it. My intent here to have less logic in my template if that makes sense. |
|
Hey sorry to check in super late here, is this still relevant?
What does this mean? Collections should be available inside of |
|
So imaging |
|
In 1.0 we did add |
|
#1933 was the issue for it |
|
Sorry for the late reply to this - but would that data include collections? It looks like it doesn't. |
Is your feature request related to a problem? Please describe.
My initial need was to build a "stats page" for an 11ty site. By that I mean, the total # of posts, information about category/tag usage, first post, last post, etc. I could have used a Liquid template to generate this data, but instead I wanted to use a JS data file so I could simply work with the generated data in a template.
Because my blog posts use tags to describe content, and not to define them as "posts", I had used my 11ty config to add a custom collection called posts based on the folder where I kept them.
My thinking was to use this collection in my JS data file, but it looks like we don't have access to them. So one ask would be to perhaps document that. My guess is that the JS data files bootstrap at the same time as the site itself, but I kinda thought they might be run after the config is setup. Maybe we can ensure that somehow? Or maybe it IS done later, but we simply don't have access to it.
So I guess my ask is - can we get access to everything templates have? I'd expect this to come in via arguments passed to my JS function.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe alternatives you've considered
In my case, I just ended up using EJS. I don't like using it for my templates, but for this complex data need - it worked well.
The text was updated successfully, but these errors were encountered: