Simple include mechanism for Metalsmith
  • JavaScript 100%
Find a file
2018-03-15 13:40:55 -07:00
.gitignore Initial commit 2017-10-31 19:22:17 -07:00
index.js allow recursive includes 2018-03-15 13:40:55 -07:00
package-lock.json add extend dep 2017-11-01 18:51:18 -07:00
package.json allow recursive includes 2018-03-15 13:40:55 -07:00
README.md add pattern matching 2017-11-01 18:49:35 -07:00

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

  • 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

License

The MIT License (MIT)

Thanks

This plugin was developed at Oportun, Inc.