Transform the content of files using layouts.
As the name suggest this is a hoast module. The module has been based of metalsmith-layouts.
Install hoast-layout using npm.
$ npm install hoast-layout
directories
: A string or array of string leading to the directories containing the layouts. If an array is provided it will search through the directories in the given order and use the first valid result. If no directory is given it will assume the root source directory.- Type:
String
orArray of Strings
- Required:
no
- Required:
- Type:
extension
: The extension of the layout. This option can be ignored and any extension can be provided by the default layout option or the frontmatter. The format should only include the extension without any punctuation before the string, for examplemd
instead of.md
.- Type:
String
- Required:
no
- Type:
layouts
: Path to default layout if the frontmatter of the file does not specify another layout using a field namedlayouts
orlayout
.- Type:
String or Array of strings
- Required:
no
- Required:
- Type:
wrappers
: Path to optional secondary layout to wrap the file's content in after the main layout has done its job. Do note this can not be overwritten via the frontmatter.- Type:
String or Array of strings
- Required:
no
- Type:
options
: Options given to the JSTransformer.- Type:
Object
- Default:
{}
- Default:
- Type:
patterns
: Glob patterns to match file paths with. If the engine function is set it will only give the function any files matching the pattern.- Type:
String
orArray of strings
- Default:
[ '**/*.md', '**/*.markdown' ]
- Default:
- Type:
patternOptions
: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.- Type:
Object
- Default:
{}
- Type:
patternOptions.all
: This options is added topatternOptions
, and determines whether all patterns need to match instead of only one.- Type:
Boolean
- Default:
false
- Type:
From 0.2.0 and up the
directory
option has been deprecated and is replaced by thedirectories
option.
Cli
{
"modules": {
"read": {},
"hoast-layout": {
"directory": "layouts",
"layouts": "default.hbs",
"wrappers": "wrapper.hbs",
"patterns": "*.html"
}
}
}
Script
const Hoast = require(`hoast`);
const read = Hoast.read,
layout = require(`hoast-layout`);
Hoast(__dirname)
.use(read())
.use(layout({
directory: `layouts`
layouts: `default.hbs`,
wrappers: `wrapper.hbs`,
patterns: `*.html`
}))
.process();
In the examples the HTML files are entered into the handlebars layout.
If you are having problems with the module please enable debugging to have a closer look.
File not valid for processing.
- The file is not utf-8 encoded.
- The file path does not match any of the patterns.
No valid transformer found for extension .
- Check if the JSTransformer associated with the extension is installed.