mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-04 17:01:41 -05:00
Added the ability to add content to multiple collections
This commit is contained in:
parent
412e5ef612
commit
8854628743
1 changed files with 14 additions and 6 deletions
20
lib/index.js
20
lib/index.js
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue