mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-04 17:21:37 -05:00
Layouts instead of templates, closes #2
This commit is contained in:
parent
584e0f108c
commit
77e13d8558
1 changed files with 6 additions and 6 deletions
12
lib/index.js
12
lib/index.js
|
@ -1,6 +1,6 @@
|
|||
|
||||
var consolidate = require('consolidate');
|
||||
var debug = require('debug')('metalsmith-templates');
|
||||
var debug = require('debug')('metalsmith-layouts');
|
||||
var each = require('async').each;
|
||||
var extend = require('extend');
|
||||
var match = require('multimatch');
|
||||
|
@ -19,7 +19,7 @@ module.exports = plugin;
|
|||
var settings = ['engine', 'directory', 'pattern', 'default'];
|
||||
|
||||
/**
|
||||
* Metalsmith plugin to run files through any template in a template `dir`.
|
||||
* Metalsmith plugin to run files through any layout in a layout `dir`.
|
||||
*
|
||||
* @param {String or Object} options
|
||||
* @property {String} default (optional)
|
||||
|
@ -35,7 +35,7 @@ function plugin(opts){
|
|||
if (!opts.engine) throw new Error('"engine" option required');
|
||||
|
||||
var engine = opts.engine;
|
||||
var dir = opts.directory || 'templates';
|
||||
var dir = opts.directory || 'layouts';
|
||||
var pattern = opts.pattern;
|
||||
var def = opts.default;
|
||||
var params = omit(opts, settings);
|
||||
|
@ -45,9 +45,9 @@ function plugin(opts){
|
|||
|
||||
function check(file){
|
||||
var data = files[file];
|
||||
var tmpl = data.template || def;
|
||||
var lyt = data.layout || def;
|
||||
if (pattern && !match(file, pattern)[0]) return false;
|
||||
if (!tmpl) return false;
|
||||
if (!lyt) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ function plugin(opts){
|
|||
debug('converting file: %s', file);
|
||||
var data = files[file];
|
||||
var clone = extend({}, params, metadata, data);
|
||||
var str = metalsmith.path(dir, data.template || def);
|
||||
var str = metalsmith.path(dir, data.layout || def);
|
||||
var render = consolidate[engine];
|
||||
|
||||
render(str, clone, function(err, str){
|
||||
|
|
Loading…
Add table
Reference in a new issue