Added the ability to add content to multiple collections

This commit is contained in:
Anthony Short 2014-08-12 13:54:44 -07:00
parent 412e5ef612
commit 8854628743

View file

@ -38,7 +38,7 @@ function plugin(opts){
match(file, data).forEach(function(key){
metadata[key] = metadata[key] || [];
metadata[key].push(data);
data.collection = key;
// data.collection = key;
});
});
@ -154,12 +154,20 @@ function matcher(cols){
return function(file, data){
var matches = [];
var key = data.collection;
if (key && ~keys.indexOf(key)) matches.push(key);
for (key in matchers){
var m = matchers[key];
if (m && m.match(file)) matches.push(key);
var collections = data.collection || [];
if (!Array.isArray(collections)) {
collections = [collections];
}
collections.forEach(function(key){
if (key && ~keys.indexOf(key)) matches.push(key);
for (key in matchers){
var m = matchers[key];
if (m && m.match(file)) matches.push(key);
}
});
return unique(matches);
};
}