Nearly Perpendicular Macaroons
Miss any of our Open RFC calls?Watch the recordings here! »

metalsmith-replace

0.0.5 • Public • Published

metalsmith-replace

An attribute's value replace plugin for metalsmith

Install

npm install metalsmith-replace

Usage

var metalSmith = require('metalsmith');
var replace = require('metalsmith-replace');
 
var metalsmith = metalSmith(__dirname);
metalsmith
    .source('post')
    .use(replace({
        title: function(title){
            return title.replace('aaa', 'bbb');
        },
        content: function(content){
            return content.replace('str1', 'str2');
        }
    }))
    .use(replace({
        title: {
            from: 'a.md',
            to: 'b.md'
        }
    }))
    .build();

Options

The keys of options is the attribute name of your files, and value should to be a object, function, or array which contains object or function;

when object, it should have attribute from and to, and the value of from can be string or regex

when function, the signature is function(oldValue){}, and the function should return the new value

when array, it should contains object or function above

License

MIT

Install

npm i [email protected]

Version

0.0.5

License

MIT

Last publish

Collaborators

  • avatar
  • avatar