Giter VIP home page Giter VIP logo

Comments (8)

ianstormtaylor avatar ianstormtaylor commented on July 22, 2024

I thought about it for a second when writing this originally but then got scared of the possibilities and didn't implement it haha. Would be curious to hear how you want to do it. The problem I saw was that it makes the single collection case more annoying to deal with? Maybe it can be behind a flag somehow.

from collections.

leeola avatar leeola commented on July 22, 2024

I'm not sure i understand how it makes a single collection more annoying to deal with? I mean, for the metalsmith-collections code of course, it's more annoying. From the UX perspective it's nearly identical for a user to add One Collection, or two (depending on the syntax).

Ie:

---
collection: foo
---
metal.use collections({
  foo: {}
})

vs

---
collection: foo bar
---
metal.use collections({
  foo: {},
  bar: {}
})

The syntax doesn't really change for the user. Now, the YAML is obviously wrong there.. in the sense that it's not a list. I believe collection: [foo, bar] would be the correct example. But even then, we could support [foo, bar] and 'foo' wouldn't be hard imo.

Perhaps (likely lol) i'm forgetting/missing something? I'm quite new to the project :)

from collections.

ianstormtaylor avatar ianstormtaylor commented on July 22, 2024

Ah, the one place where I see it gets more annoying is the .collection property added to the files. I've been using that in templates so that each file can know which collection it's in. Would need to be an array I guess for multiples, which makes the single case a bit uglier sadly.

from collections.

leeola avatar leeola commented on July 22, 2024

Perhaps a different namespace? collection and collections.

I'm not sure what collection would be, if there were many collections, but on the flipside collections would always be one or more items, within a list.

This would be something each user opts into, per document, so in theory they're responsible for handling the change in output (imo) - but i agree consistency is always optimal

from collections.

ianstormtaylor avatar ianstormtaylor commented on July 22, 2024

Yeah I think if we keep it behind a multiple flag that might work. And if multiple: false then we just grab the first collection in the YAML array. That way the simple case is foremost, but multiple can be achieved when needed. Multiple would add collections and single would add collection but never both.

from collections.

leeola avatar leeola commented on July 22, 2024

Sounds good, how would you like to see the multiple flag specified?

from collections.

ianstormtaylor avatar ianstormtaylor commented on July 22, 2024

Damn. I forgot this plugin just takes top-level collections. I guess we should change it to:

{
  collections: { ... },
  multiple: true
}

That would be kind of nice anyways, because it means we could have other top-level defaults across all collections like sortBy which I've been duplicating for now.

from collections.

ianstormtaylor avatar ianstormtaylor commented on July 22, 2024

btw, @anthonyshort just added support for this: #19

from collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.