Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Last active October 16, 2017 06:29
Show Gist options
  • Save doublejosh/30a19a85b324b3542a62ae21262a6967 to your computer and use it in GitHub Desktop.
Save doublejosh/30a19a85b324b3542a62ae21262a6967 to your computer and use it in GitHub Desktop.
Install via metalsmith-plugin-template/index.js
/**
* @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