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

Paginated collections do not inherit data from root page #961

Open
chriskrycho opened this issue Feb 24, 2020 · 2 comments
Open

Paginated collections do not inherit data from root page #961

chriskrycho opened this issue Feb 24, 2020 · 2 comments

Comments

@chriskrycho
Copy link

Describe the bug

I'm generating tag pages as suggested by Paging a Collection. In general, this works quite well! 🎉 However, the pages generated this way do not inherit the data from the root template used to generate the paginated view.

The problem here is that the resulting pages don't have any way of filtering on them other than perhaps by URL or digging down into the data on the object: they don't appear in any collections generated from the root template in particular. As such, they have to be special-cased in some way.

To Reproduce
Steps to reproduce the behavior:

  1. Generate a paginated collection.
  2. Include the root file for that paginated collection in a (separate) collection itself in some way. (tags, custom collections, etc.). E.g. put it in a pages collection.
    • for extra clarity, set addAllPagesToCollections: true
  3. Render items that should filter to include or exclude items matching the collection (e.g. pages).
  4. Observe that none of the rendered items (e.g. individual tag pages) are appropriately filtered. 😱 If you dig into the data, you will note that they have the original item's metadata (e.g. the page tag), but this does not translate into their being included in the collection generated but that metadata.

Expected behavior

Each item rendered by the template is included in whatever collection(s) the template itself is included in and can be filtered accordingly.

Environment:

  • OS and Version: macOS 10.15.3
  • Eleventy Version 0.10.0
chriskrycho added a commit to chriskrycho/v5.chriskrycho.com that referenced this issue Feb 24, 2020
Excluding items by collection does not currently work with 11ty's
paginated collections. Work around it by supplying a special case for
dealing with `standalonePage: true`.
@chriskrycho
Copy link
Author

I worked around this issue on my own website in this commit.

@edwardhorsford
Copy link
Contributor

@chriskrycho I don't know if it helps, but I have filters for grabbing paginated or non-paginated pages. I think this would help you avoid needing to set standalonePage: true in your frontmatter.

// Items that are paginated by Eleventy
exports.paginatedOnly = (items) => {
	return items.filter( item => {
		return (typeof item.data.pagination !== 'undefined')
	})
}

// Items that are not paginated
exports.nonPaginatedOnly = (items) => {
	return items.filter( item => {
		return (typeof item.data.pagination == 'undefined')
	})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants