At it's core, a plugin is a function that takes some configuration parameters, and then produces another function. The signature of that function is like this:
function(files, metalsmith, done)
The files object is an object in which every key represents a path in a virtual file system, and its value an object that contains both metadata and the actual contents, as a Buffer, stored under the contents key.
So a simple example adding a robots.txt file would look like this:
In this particular example, I've added the markdown plugin (one that is installed with npm install -S metalsmith-markdown), and also added the example robots.txt plugin I created a minute ago. The destination(…) call makes sure all plugins run in order, and the result is written to de destination folder. Alternatively, you could also use the metalsmith-serve plugin to serve the web site directly.
see the rise of the smiths:
At it's core, a plugin is a function that takes some configuration parameters, and then produces another function. The signature of that function is like this:
The files object is an object in which every key represents a path in a virtual file system, and its value an object that contains both metadata and the actual contents, as a Buffer, stored under the contents key.
So a simple example adding a robots.txt file would look like this:
Here's how you add that plugin:
In this particular example, I've added the markdown plugin (one that is installed with npm install -S metalsmith-markdown), and also added the example robots.txt plugin I created a minute ago. The destination(…) call makes sure all plugins run in order, and the result is written to de destination folder. Alternatively, you could also use the metalsmith-serve plugin to serve the web site directly.