add collections dictionary to global metadata

This commit is contained in:
Ian Storm Taylor 2014-03-20 16:50:16 -07:00
parent c15a2c0ab7
commit bd1d662b25
2 changed files with 12 additions and 1 deletions

View file

@ -75,6 +75,15 @@ function plugin(opts){
});
});
/**
* Add them grouped together to the global metadata.
*/
metadata.collections = {};
keys.forEach(function(key){
return metadata.collections[key] = metadata[key];
});
done();
};
}

View file

@ -10,7 +10,9 @@ describe('metalsmith-collections', function(){
.use(collections({ articles: {}}))
.build(function(err){
if (err) return done(err);
assert.equal(2, metalsmith.metadata().articles.length);
var m = metalsmith.metadata();
assert.equal(2, m.articles.length);
assert.equal(m.collections.articles, m.articles);
done();
});
});