You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I set a variable in eleventyComputed, then try to use that variable in the current page, it has no value. However, if I loop over a collection containing the page with the eleventyComputed value it's properly set and accessible as item.data.variableName.
The page I've been using to test this uses pagination, but I'm not trying to use computed data in pagination as was done in several other reported issues. This happens even if I just use a simple string for the value in eleventyComputed.
The built output of a page with two variables set in eleventyComputed, title and nottitle, has no value for either {{ title }} or {{ nottitle }} when they are used in the HTML of the same page.
However, in a previous attempt I was able to get a value for the second variable. This scenario has been reproduced by unaffiliated developers.
When I loop over the pages with these computed variables in a collection (e.g. {% for item in collections.months %}), both item.data.title and item.data.nottitle are available.
The behavior suggests to me that there might be an asynchronous function somewhere that's not resolving in time for the current page.
This index page works fine. Both month.data.title and month.data.nottitle have the expected values.
Expected behavior
I expected the variables set in eleventyComputed to be available in the current page.
I thought there might be something special about the title variable, but I was later able to reproduce the problem with arbitrary variable names.
I thought there might be some issue with using pagination data in eleventyComputed (not using computed data in pagination), but I was able to reproduce the problem when setting the variable values to a simple string.
Hi, this is specifically a problem with nunjucks. If you change your templates to liquid, md, handlebars, etc... it will work properly and eleventyComputed values will be computed
Operating system
Windows 11
Eleventy
2.0.1
Describe the bug
If I set a variable in
eleventyComputed
, then try to use that variable in the current page, it has no value. However, if I loop over a collection containing the page with theeleventyComputed
value it's properly set and accessible as item.data.variableName.The page I've been using to test this uses pagination, but I'm not trying to use computed data in pagination as was done in several other reported issues. This happens even if I just use a simple string for the value in
eleventyComputed
.I created a GitHub repo demonstrating the problem: https://github.com/VAggrippino/eleventy-computed-title
The built output of a page with two variables set in
eleventyComputed
,title
andnottitle
, has no value for either{{ title }}
or{{ nottitle }}
when they are used in the HTML of the same page.However, in a previous attempt I was able to get a value for the second variable. This scenario has been reproduced by unaffiliated developers.
When I loop over the pages with these computed variables in a collection (e.g.
{% for item in collections.months %}
), bothitem.data.title
anditem.data.nottitle
are available.The behavior suggests to me that there might be an asynchronous function somewhere that's not resolving in time for the current page.
Reproduction steps
npx @11ty/eleventy
{{ title }}
or{{ nottitle }}
https://github.com/VAggrippino/eleventy-computed-title/blob/main/index.njk :
This index page works fine. Both
month.data.title
andmonth.data.nottitle
have the expected values.Expected behavior
I expected the variables set in
eleventyComputed
to be available in the current page.I thought there might be something special about the
title
variable, but I was later able to reproduce the problem with arbitrary variable names.I thought there might be some issue with using pagination data in
eleventyComputed
(not using computed data inpagination
), but I was able to reproduce the problem when setting the variable values to a simple string.Reproduction URL
https://github.com/VAggrippino/eleventy-computed-title
Screenshots
Pictured in the screenshot is Vivaldi because it has a really nice tiled tabs feature, but all testing was done in Google Chrome.
The text was updated successfully, but these errors were encountered: