mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-04 17:01:41 -05:00
Merge pull request #25 from boushley/master
Allow front matter and pattern collections.
This commit is contained in:
commit
0d84c978ba
2 changed files with 22 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue