A very simple Metalsmith plugin that allows content to be included with a directive.
npm install --save-dev metalsmith-simple-includes
const includes = require( 'metalsmith-simple-includes' );
Metalsmith( __dirname )
.use( includes( {
directive: '^#include <(.*?)>', // default include directive pattern
directory: '', // default includes directory
pattern: '*.html' // default file pattern to process for include directives
} ) )
.build( error => {
if ( error ) {
console.error( error )
}
} );
#include <path/to/file.ext>
{
"plugins": {
"metalsmith-simple-includes": {
"directive": "^#include <(.*?)>",
"directory": "",
"pattern": "*.html"
}
}
}
-
directive
is the regular expression for the include directive -
directory
is the base directory for your included files -
pattern
is a glob pattern for filenames to process for include directives
The MIT License (MIT)
This plugin was developed at Oportun, Inc.