diff --git a/lib/index.js b/lib/index.js index 2a9f0d5..2e06a52 100644 --- a/lib/index.js +++ b/lib/index.js @@ -175,11 +175,10 @@ function matcher(cols){ debug('adding new collection through metadata: %s', key); }); } - else { - for (var key in matchers){ - var m = matchers[key]; - if (m && m.match(file)) matches.push(key); - } + + for (var key in matchers){ + var m = matchers[key]; + if (m && m.match(file)) matches.push(key); } data.collection = unique(matches); diff --git a/test/index.js b/test/index.js index b7a0715..c816eea 100644 --- a/test/index.js +++ b/test/index.js @@ -283,4 +283,22 @@ describe('metalsmith-collections', function(){ }); }); + it('should allow collections by pattern and front matter', function (done) { + var metalsmith = Metalsmith('test/fixtures/multi'); + metalsmith + .use(collections({ articles: {}, posts: {}, drafts: {}, blog: '*.md' })) + .build(function(err){ + if (err) return done(err); + var m = metalsmith.metadata(); + assert.equal(3, m.blog.length); + assert.equal(2, m.articles.length); + assert.equal(1, m.drafts.length); + assert.equal(1, m.posts.length); + assert.equal(m.collections.blog, m.blog); + assert.equal(m.collections.articles, m.articles); + assert.equal(m.collections.drafts, m.drafts); + assert.equal(m.collections.posts, m.posts); + done(); + }); + }); });