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

eleventyComputed not working after 2.0.0-canary.8 #2512

Open
oliwarner opened this issue Jul 27, 2022 · 5 comments
Open

eleventyComputed not working after 2.0.0-canary.8 #2512

oliwarner opened this issue Jul 27, 2022 · 5 comments
Labels
feature: 🧮 computed data Related to Eleventy’s Computed Data feature needs-triage

Comments

@oliwarner
Copy link

I've just upgraded to 2.0.0-canary.14 from 1.0.1. Almost everything worked great except my tag page.

---
pagination:
  data: collections
  size: 1
  alias: tag
permalink: /tag/{{ tag | slug }}/index.html
eleventyComputed:
  title: "{{ tag | title }}"
---
<header class="tag">
  <h1>{{ title }}</h1>
</header>

I use eleventyComputed and a filter to recondition the lowercase tags into something more readable. I do it here so I can use it in the <title> tag and OG metadata, as well as on the page.

After upgrading, this doesn't work. title is just empty. I've seen a post on another bug suggesting this crept in 2.0.0-canary.9 but I can't see anybody else having this problem.

@zachleat zachleat added the feature: 🧮 computed data Related to Eleventy’s Computed Data feature label Aug 15, 2022
@NotIntelli
Copy link

NotIntelli commented Feb 25, 2023

I'm having the same problem with eleventyComputed returning an empty string while paginating

title: GenericTitle
pagination:
    data: collections
    size: 1
    alias: tag
permalink: /tags/{{ tag }}/
eleventyComputed:
    code: "_tag{{ tag }}" #Becomes ""
collection: tag
layout: index
eleventyExcludeFromCollections: true

code just becomes empty. Removing {{ tag }} from the computed value still causes code to be empty.

title: GenericTitle
pagination:
    data: collections
    size: 1
    alias: tag
eleventyComputed:
    code: "foo" #Becomes "" when it should be "foo"
permalink: /tags/{{ tag }}/
collection: tag
layout: index
eleventyExcludeFromCollections: true

Seems as if eleventyComputed doesn't work with pagination at all

@pdehaan
Copy link
Contributor

pdehaan commented Feb 25, 2023

I think this is working for me in 2.0.0 final:
https://github.com/pdehaan/11ty-2512/blob/main/src/tags.liquid

And my output www/tags/home/index.html has the following content:

<h1>home</h1>

code="foo"

@lucasnantonio
Copy link

I am also observing this issue when trying to follow the tag pagination instructions. Title is not being computed.
Even on ^2.0.2-alpha.2

@MatthewNichols
Copy link

I am seeing something similar: In 2.0.1 I have a template with this front matter:
--- pagination: data: events.parsed.allLocalPages size: 1 alias: event permalink: "events/{{ event.slug }}.html" eleventyComputed: title: "{{ event.name }}" ---

The title is being computed fine normally, but when I added title in a directory data file one level up:
module.exports = { title: "blah blah" };
then the computed title in the paginated pages is returning ''.

I tried 2.0.2-alpha.2 and get the same result.

@alifeee
Copy link

alifeee commented Dec 10, 2023

Hi all, 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

more info -> #3120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: 🧮 computed data Related to Eleventy’s Computed Data feature needs-triage
Projects
None yet
Development

No branches or pull requests

7 participants