eleventy: eleventyComputed is not returning data
---
pagination:
data: standards
size: 1
alias: standard
addAllPagesToCollections: true
permalink: "{{ standard.slug }}/index.html"
eleventyComputed:
title: "{{ standard.name }}"
---
Doesn’t return anything for the <title>
.
Prior, I was using {% set title = standard.name %}
, but this doesn’t get elevated to collections.all
(returns empty for dynamic pages)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 21 (7 by maintainers)
@jasonday to access computed variables, use:
If you’re also sometimes using
{{ title }}
, then do this:Is this by design? I figured it out via trial-and-error, but somehow the documentation had left me with an assumption that the
eleventyComputed
contents would be “woven in” and override page data.I have similar problems with Nunjuck templates in computed data properties. Some values from the data cascade seem to be accessible (e.g.
title
) while others don’t (e.g.collections
). I setup a test repository to demonstrate my issue. If I use javascript front matter insrc/posts/posts.njk
everything is working as expected.dweidner/eleventy-computed-front-matter
I also tried the current master branch, same problems. Could it be that collections are simply not yet available at that point of time?
Giving unexpected results:
Works as expected:
Sorry, I haven’t had time to create a test case and ended up using
renderData
, which did work.So, I’ll still create a test case, but I was able to get it all working with
renderData
- populating a page title and populatingcollections.all
, which was the primary issue.@binyamin I’ll see what I can come up with. I’m using fully dynamic data sources that won’t be available from outside our internal netwek, so I’ll have to use dummy JSON and change a bunch to get it to be functional.