5t3ph / 11ty-rocks

A collection of Eleventy (11ty) starters, projects, plugins, and resources created by Stephanie Eckles (@5t3ph)

Home Page:https://11ty.rocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Group Tags Together - Example doesn't work as described

webmanufaktur opened this issue · comments

https://11ty.rocks/posts/creating-and-using-11ty-collections/#group-tags-together

Described as:
Will show/create a merge of collections based on/of 2 tags.
= content with tags either/or "post" OR "page"

Result is:
Does only show/create a collection of pages that have both tags "page" AND "post".

Difference:
Posts need BOTH tags "post" AND "page" to be in that new collection, instead of either/or.

Either there is another setting (in .eleventy.js/config.eleventy.js) that's missing here or... ???

Doesn't work as described/expected in either 11ty@1/11ty@2.

Let me know if I miss something crucial here or ... else.

11ty docs describe it "correct":
https://www.11ty.dev/docs/collections/

Retrieve content that includes ALL of the tags passed in. Returns an array.

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