Skip to content
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

Get rid of collection object pollution due tag 'over-use' #1668

Closed
hidegh opened this issue Mar 1, 2021 · 4 comments
Closed

Get rid of collection object pollution due tag 'over-use' #1668

hidegh opened this issue Mar 1, 2021 · 4 comments
Labels
duplicate enhancement open-question Requires additional information before we can proceed.

Comments

@hidegh
Copy link

hidegh commented Mar 1, 2021

Describe the bug
Due to tags the collection object get's easily polluted - especially with lot of tags in use - see: https://www.11ty.dev/docs/collections/#multiple-tags-multiple-lines

Plz. consider using a collection.tags as an object which holds all the automatically resolved collections by a concrete tag...
...so the code in the sample (documentation) would turn to collection.tags.cat, collection.tags.dog

Would be ideal to introduce this in a major version change, so 1.x
@zachleat

To Reproduce
See current behavior with 20+ tags...

Expected behavior
Minimal change in the collection object, making it less polluted (avoiding eventual overwrites with manually added collections, etc.)

Screenshots
n/a

Environment:

  • OS and Version: w10
  • Eleventy Version: 0.11.1

Additional context
n/a

@zachleat
Copy link
Member

Sorry, I don’t think I quite understand—why is collections.tags.cat better than collections.cat?

@zachleat zachleat added the open-question Requires additional information before we can proceed. label Mar 18, 2021
@edwardhorsford
Copy link
Contributor

edwardhorsford commented Mar 19, 2021

@zachleat To me, the current set up pollutes the collections namespace - especially when you have lots of tags. I have lots of other things in frontmatter / under collections, and I don't need my tags all at that level too - I'd much prefer if all my tags were collected under a namespace.

The other way of looking at it is that they're all of a certain type of thing - so it makes sense they be under their own namespace. If I was adding other data that has multiple of a thing I'd likely put it under a namepsace to collect them.

I think I've seen a number of issues discuss this - will try to dig up.

Another possible use would be that it could be easier to work with them - right now if a template wants to iterate over tags, they'd can't just read them - as collections has other stuff too. You'd need a custom collection to collect a second copy of tags to expose them in an iterable way.

@edwardhorsford
Copy link
Contributor

Related: #1254

@zachleat
Copy link
Member

zachleat commented Aug 6, 2021

Ah hmm—I think we should probably organize over at #1254 for this one. More progress over there, thanks!

@zachleat zachleat closed this as completed Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate enhancement open-question Requires additional information before we can proceed.
Projects
None yet
Development

No branches or pull requests

3 participants