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

Pagination fails on collections['tag with spaces'] but not collections.tag with spaces #2851

Closed
Aankhen opened this issue Mar 9, 2023 · 3 comments
Labels

Comments

@Aankhen
Copy link

Aankhen commented Mar 9, 2023

Operating system

Windows 10 64-bit

Eleventy

2.0.0

Describe the bug

Paginating collections['tag with spaces'] fails, but collections.tag with spaces works.

Reproduction steps

Given post.njk:

---
tags: ['tag with spaces']
---

This is a post.

Paginating collections['tag with spaces'] fails:

❯❯ cat posts.njk
---
pagination:
  data: "collections['tag with spaces']"
  size: 1
---

This is the tag page.

❯❯ npx @11ty/eleventy
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] Could not find pagination data (./posts.njk), went looking for: collections['tag with spaces'] (via Error)
[11ty]
[11ty] Original error stack trace: Error: Could not find pagination data (./posts.njk), went looking for: collections['tag with spaces']
[11ty]     at Pagination._get (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\Plugins\Pagination.js:166:13)
[11ty]     at Pagination.setData (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\Plugins\Pagination.js:86:29)
[11ty]     at new Pagination (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\Plugins\Pagination.js:24:10)
[11ty]     at Template.getTemplates (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\Template.js:703:21)
[11ty]     at TemplateMap.initDependencyMap (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\TemplateMap.js:435:41)
[11ty]     at async TemplateMap.cache (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\TemplateMap.js:486:5)
[11ty]     at async TemplateWriter._createTemplateMap (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\TemplateWriter.js:330:5)
[11ty]     at async TemplateWriter.generateTemplates (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\TemplateWriter.js:360:5)
[11ty]     at async TemplateWriter.write (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\TemplateWriter.js:407:23)
[11ty]     at async Eleventy.executeBuild (D:\Media\src\my\eleventy-pagination-test\node_modules\@11ty\eleventy\src\Eleventy.js:1160:13)
[11ty] Wrote 0 files in 0.03 seconds (v2.0.0)

But collections.tag with spaces works:

❯❯ cat posts.njk
---
pagination:
  data: "collections.tag with spaces"
  size: 1
---

This is the tag page.

❯❯ npx @11ty/eleventy
[11ty] Writing _site/post/index.html from ./post.njk
[11ty] Writing _site/posts/index.html from ./posts.njk
[11ty] Wrote 2 files in 0.05 seconds (v2.0.0)

When I added

Expected behavior

No response

Reproduction URL

https://github.com/Aankhen/11ty-pagination-bug

Screenshots

No response

@Aankhen
Copy link
Author

Aankhen commented Mar 9, 2023

By fiddling with the local copy of Pagination.js, I noticed that setCollectionByTagName is called in the second (functional) case but not the first.

@zachleat zachleat added this to the Eleventy 2.0.1 milestone Mar 21, 2023
@zachleat zachleat added bug and removed needs-triage labels Mar 21, 2023
@zachleat
Copy link
Member

Successfully reproduced!

@zachleat
Copy link
Member

Fix will ship with 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants