11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
16.58k stars 481 forks source link

Custom template engine option to exclude from `collections.all` #2854

Open zachleat opened 1 year ago

zachleat commented 1 year ago

Like eleventyExcludeFromCollections but set in https://www.11ty.dev/docs/languages/custom/ somewhere.

cc @5t3ph

https://github.com/5t3ph/eleventy-plugin-sass-lightningcss#usage

⚠️ Important: The files will end up in collections.all and appear in places like RSS feeds where you may be using the "all" collection. To prevent that, https://github.com/11ty/eleventy/discussions/2850#discussioncomment-5254892 is to create a directory data file to exclude your Sass files.

Just thinking out loud: maybe it’d be nice to have a collections entry for HTML-only stuff? Or even more breakingly, should collections.all include non-HTML files (probably not this, that’s too big of a breaking change)?

Related: https://www.11ty.dev/docs/languages/custom/#outputfileextension

patrulea commented 1 year ago

It could also look like having control over what goes into the collection by handling what it’s aggregating. Maybe:

A: Compose an array with template (or output) extensions. Kinda like templateFormats.
B: Opt in or out of extensions. Kinda like ignores.add and ignores.delete.

elmuerte commented 10 months ago

Both eleventyExcludeFromCollections and pagination:addAllPagesToCollections could also use some granular controls.

For example:

pagination:
  addAllPagesToCollections: true
tags:
  - foobar
  - quux

This will add it to all collections

pagination:
  addAllPagesToCollections:
    - all
    - foobar
tags:
  - foobar
  - quux

That would only add it to the "all" and "foobar" collections, but not to the "quux" collection.

For eleventyExcludeFromCollections the similar approach could be used. But it becomes a bit more tricky. true would exclude it from everything [all, foobar] would exclude it from the "all" and "foobar" collection. But what if you want to exclude it from all collections, except for "quux"? Maybe add a eleventyIncludeInCollections which defaults to true and does the exact opposite?

zachleat commented 1 week ago

Related #2830 and #2482 both shipping with 3.0