mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-05 09:31:39 -05:00
Merge pull request #23 from superwolff/ignore-binary
Ignore binary files
This commit is contained in:
commit
567305df87
2 changed files with 8 additions and 3 deletions
10
lib/index.js
10
lib/index.js
|
@ -4,6 +4,7 @@ var each = require('async').each;
|
|||
var extend = require('extend');
|
||||
var match = require('multimatch');
|
||||
var omit = require('lodash.omit');
|
||||
var utf8 = require('is-utf8');
|
||||
|
||||
/**
|
||||
* Expose `plugin`.
|
||||
|
@ -41,10 +42,12 @@ function plugin(opts){
|
|||
|
||||
return function(files, metalsmith, done){
|
||||
var metadata = metalsmith.metadata();
|
||||
var matches = {};
|
||||
|
||||
function check(file){
|
||||
var data = files[file];
|
||||
var lyt = data.layout || def;
|
||||
if (!utf8(data.contents)) return false;
|
||||
if (pattern && !match(file, pattern)[0]) return false;
|
||||
if (!lyt) return false;
|
||||
return true;
|
||||
|
@ -55,15 +58,16 @@ function plugin(opts){
|
|||
debug('stringifying file: %s', file);
|
||||
var data = files[file];
|
||||
data.contents = data.contents.toString();
|
||||
matches[file] = data;
|
||||
});
|
||||
|
||||
each(Object.keys(files), convert, done);
|
||||
each(Object.keys(matches), convert, done);
|
||||
|
||||
function convert(file, done){
|
||||
if (!check(file)) return done();
|
||||
debug('converting file: %s', file);
|
||||
var data = files[file];
|
||||
var clone = extend({}, params, metadata, data);
|
||||
var clonedParams = extend(true, {}, params);
|
||||
var clone = extend({}, clonedParams, metadata, data);
|
||||
var str = metalsmith.path(dir, data.layout || def);
|
||||
var render = consolidate[engine];
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"consolidate": "^0.13.1",
|
||||
"debug": "^2.2.0",
|
||||
"extend": "^3.0.0",
|
||||
"is-utf8": "^0.2.0",
|
||||
"lodash.omit": "^3.1.0",
|
||||
"multimatch": "^2.0.0"
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue