-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Is it possible to filter all collections at once? #823
Comments
Use this gist to filter the array by key:value pair at the point of setting the collection in the template language. Tested to work with nunjucks and liquid. https://gist.github.com/danfascia/e15b8e900a767c1b9677d1cbc74cc51c |
@danfascia sorry, I don't understand how to use it, could you link to an usage example? thanks |
@nhoizey This filter is used by @paulrobertlloyd to select elements from a collection Maybe not quiet what you're looking for, as you don't wan't those elements listed in your collection at all if I understand. You might want to filter drafts in the collection like @rem does. It's quiet similar to what you do. From what I understand, you want to make it a function you could use in all your collections? |
As an aside, if you are using Liquid for templating, it’s builtin |
@paulrobertlloyd I'm using Nunjucks… 😅 @DirtyF I would like to filter draft content out of all collections without having to define collections in Maybe @danfascia's solution but inverted ( |
I'm using Forestry to edit content for a site generated with Eleventy, and it manages drafts with a YFM variable named
published
with valuesfalse
andtrue
.I would like to filter out all drafts, but it currently requires defining all collections one after the other in
.eleventy.js
and filter out the items that havepublished: false
:nhoizey/precious-prana.com@19d20ec
Every time I had a collection, I will have to remember adding this.
Is there a simpler way?
The text was updated successfully, but these errors were encountered: