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

Proposal: Use arrify to support both array and object rules #4

Open
blakeembrey opened this issue Oct 29, 2015 · 1 comment
Open

Proposal: Use arrify to support both array and object rules #4

blakeembrey opened this issue Oct 29, 2015 · 1 comment

Comments

@blakeembrey
Copy link

I normally prefer to use multiple instances of plugins where I need them, not multiple rules upfront. You can easily abstract this though, by accepting both.

@dpobel
Copy link
Owner

dpobel commented Dec 28, 2015

Hi @blakeembrey

you mean being able to write:

metalsmith
.use(fileMetadata(
    {pattern: "posts/*", metadata: {"section": "blogs", "type": "post"}}
))
.use(fileMetadata(
    {pattern: "pages/*", metadata: {"section": "content", "type": "page"}}
));

instead of

metalsmith.use(fileMetadata([
    {pattern: "posts/*", metadata: {"section": "blogs", "type": "post"}},
    {pattern: "pages/*", metadata: {"section": "content", "type": "page"}}
]));

?

Well, you can already write:

metalsmith
.use(fileMetadata([
    {pattern: "posts/*", metadata: {"section": "blogs", "type": "post"}}
]))
.use(fileMetadata([
    {pattern: "pages/*", metadata: {"section": "content", "type": "page"}}
]));

if you really want to separate the rules/calls.

That said, the patch would be trivial to also support a unique rule as fileMetadata parameter, so feel free to submit a pull request, I'll merge it as long as the change is documented and unit tested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants