A very simple Metalsmith plugin that adds path and filename to a file's metadata.
npm install --save-dev metalsmith-pathnames
const pathnames = require( 'metalsmith-pathnames' );
Metalsmith( __dirname )
.use( pathnames( {
pattern: '**/*.html', // default file pattern to add path/filename to
index: '**/index.html', // default index name to strip,
base: '' // default base directory,
replacements: [] // default replacements to perform on path
} ) )
.build( error => {
if ( error ) {
console.error( error )
}
} );
{
"plugins": {
"metalsmith-pathnames": {
"pattern": "**/*.html",
"index": "**/index.html",
"base": "",
"replacements": []
}
}
}
-
pattern
is the file glob to match for files to add path/filename -
index
is the file glob mathing your index to be stripped from the path -
base
is an optional base directory to add -
replacements
is an optional array of RegExp/replacement pairs
The MIT License (MIT)
This plugin was developed at Oportun, Inc.