Home

metalsmith

Four metalsmith plugins

Metalsmith plugins


Metalsmith is a pluggable file processor, built on NodeJS, generally used for creating static web sites.


The Metalsmith documentation is sparse, so I ended up writing a couple of plugins for debugging: assert and inspect. In developing them, it inspired two others: cp-r and keymaster.

All these modules are open-source, in JavaScript, available on NPM and GitHub, and use Tape for unit tests. CI is performed by Travis CI


metalsmith-assert

Test file objects with Node's assert module. For example, to test that all have a property named "title":

.use(metalsmith-assert({
    "title exists" : { actual: "title"}
} ) )


metalsmith-cp-r

Copies a folder recursively, typically to copy web assets (CSS, scripts, images) from the working directory into the metalsmith destination directory. e.g.:

.use(metalsmith-cp-r({
   from: "_directory/pathto/assets",
   to: "_destination/pathto/assets"
} ) )


metalsmith-inspect

Inspects the file objects, typically via Node's util.inspect(). To see everything:

.use(metalsmith-inspect({}))


metalsmith-keymaster

A relatively simple but powerful plugin to create new values and store them under new keys. Since that's what most plugins do, this could be considered as a "meta-plugin" for developing plugins.

For example, to add the filename as metadata under the "foo" key:

.use(keymaster({from: function(data, filePath) {
                   return filePath;
                },
                to: 'foo'}));

Uses JavaScript nodejs NPM