Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Last active October 16, 2017 06:29
Show Gist options
  • Select an option

  • Save doublejosh/30a19a85b324b3542a62ae21262a6967 to your computer and use it in GitHub Desktop.

Select an option

Save doublejosh/30a19a85b324b3542a62ae21262a6967 to your computer and use it in GitHub Desktop.

Revisions

  1. doublejosh revised this gist Oct 16, 2017. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions metalsmith-plugin-template.js
    Original file line number Diff line number Diff line change
    @@ -11,14 +11,12 @@
    */

    /**
    * Publicly available module.
    *
    * @param {object} options
    */
    module.exports = function (options) {

    /**
    * Manipulate loaded page data.
    * Manipulate loaded src file data.
    *
    * @param {object} data
    * @param {object} options
  2. doublejosh created this gist Oct 16, 2017.
    44 changes: 44 additions & 0 deletions metalsmith-plugin-template.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    /**
    * @file Plugin template.
    *
    * @example
    * var myPlugin = require('./plugins/my-plugin');
    * Metalsmith(__dirname)
    * .source('./src')
    * .destination('./build')
    * .use(myPlugin())
    * .build(function(err) {});
    */

    /**
    * Publicly available module.
    *
    * @param {object} options
    */
    module.exports = function (options) {

    /**
    * Manipulate loaded page 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);
    });
    };
    };