11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reverse selection - get all tags except one or two?

euro opened this issue · comments

commented

Describe the solution you'd like

I see you have baked in the ability to create a custom collection of a tag (or tags) using the following:

  // Get only content that matches a tag
  eleventyConfig.addCollection("myTravelPostsWithPhotos", function(collectionApi) {
    return collectionApi.getFilteredByTags("post", "travel", "photo");
  });

Is there a way to do a negative match? Something like:

 eleventyConfig.addCollection("newCollection" = collection.whatever but filter out (!'unwanted')

or even easier:

{% for post in collections.all | except('unwanted', 'another one') %}