Simple include mechanism for Metalsmith
- JavaScript 100%
| .gitignore | ||
| index.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Metalsmith Simple Includes
A very simple Metalsmith plugin that allows content to be included with a directive.
Installation
npm install --save-dev metalsmith-simple-includes
Usage
JavaScript
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>
metalsmith.json
{
"plugins": {
"metalsmith-simple-includes": {
"directive": "^#include <(.*?)>",
"directory": "",
"pattern": "*.html"
}
}
}
Options
directiveis the regular expression for the include directivedirectoryis the base directory for your included filespatternis a glob pattern for filenames to process for include directives
License
The MIT License (MIT)
Thanks
This plugin was developed at Oportun, Inc.