Skip to content

Is there a way to use 'eleventyExcludeFromCollections' in the eleventyComputed property? #2211

Answered by pdehaan
mark-reason asked this question in General
Discussion options

You must be logged in to vote

I would have expected your solution to work, but I'm struggling to figure out locally why it isnt working for me.
My quick workaround was to create a custom collection based on a tag and just re-filter the collection based on eleventyExcludeFromCollections frontmatter.

// .eleventy.js snippet
    eleventyConfig.addCollection("pages", function (collectionApi) {
        const pages = [...collectionApi.getFilteredByTag("pages")];
        return pages.filter(p => {
            return !p.data.eleventyExcludeFromCollections;
        });
    });
---
# src/pagination.njk
pagination:
    data: "pages"
    alias: "pg"
    size: 1
    addAllPagesToCollections: true
permalink: "{{ pg.permalink }}"
ta…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@darekkay
Comment options

Answer selected by mark-reason
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants