eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

eleventyComputed not working after 2.0.0-canary.8

Open oliwarner opened this issue 2 years ago • 5 comments

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.

oliwarner avatar Jul 27 '22 22:07 oliwarner

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

NotIntelli avatar Feb 25 '23 15:02 NotIntelli

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"

pdehaan avatar Feb 25 '23 22:02 pdehaan

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

lucasnantonio avatar Jul 05 '23 12:07 lucasnantonio

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.

MatthewNichols avatar Aug 09 '23 11:08 MatthewNichols

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

alifeee avatar Dec 10 '23 17:12 alifeee