metalsmith-nestedlayouts
A metalsmith plugin for nested layouts
This plugin modifies the behavior of metalsmith-layout.
It reads from collection rather than files
There are 2 distinct advantages to this behavior:
- You can add frontmatter to layouts
- Which means you can nest layouts inside another by adding a layout property in a layout
It analyzes layouts dependency and renders layouts in correct order
It checks whether or not layouts directory is inside the Metalsmith source
Therefore it won’t reread the layouts that had already been read by the Metalsmith instance.
Usage
Refer to metalsmith-layout doc for the usage. This plugin does not break the original API and can simply replace it. The only meaningful additions are that you may now add a layout
property inside a layout, and that you may set directory
to a subdirectory of source
. If you do, you probably want to delete the layouts from the Metalsmith output because they serve no practical purpose. Example:
Metalsmith
.source('./src')
.use(layouts({ directory: 'src/layouts' }))
.use(ignore('src/layouts/*'))
Credits
- Ismay Wolff for creating the awesome metalsmith-layouts, on which this plugin is based