Last active
October 16, 2017 06:29
-
-
Save doublejosh/30a19a85b324b3542a62ae21262a6967 to your computer and use it in GitHub Desktop.
Install via metalsmith-plugin-template/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file Plugin template. | |
* | |
* @example | |
* var myPlugin = require('./plugins/my-plugin'); | |
* Metalsmith(__dirname) | |
* .source('./src') | |
* .destination('./build') | |
* .use(myPlugin()) | |
* .build(function(err) {}); | |
*/ | |
/** | |
* @param {object} options | |
*/ | |
module.exports = function (options) { | |
/** | |
* Manipulate loaded src file data. | |
* | |
* @param {object} data | |
* @param {object} options | |
*/ | |
function myPlugin (data, options) { | |
} | |
/** | |
* Operate on each file. | |
* | |
* @param {object} files | |
* @param {Metalsmith} metalsmith | |
* @param {function} done | |
*/ | |
return function pluginFileWalk(files, metalsmith, done) { | |
setImmediate(done); | |
Object.keys(files).forEach(function(file) { | |
myPlugin(files[file], options); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment