Layout Loader
Wraps markdown files in a jade layout.
How it works
Layout loader works by extending the layout of your choice and injecting the markdown in a :marked
filter. See below.
extends ${layout} block ${block} :marked ${content}
Installation
Load it in app.js
like so:
moduleexports = { return defaults: } matchers: html: '**/*.(md|jade)' module: preLoaders: test: /\.md$/ loader: 'layout-loader' layout: 'my-layout'
Configuration
Layout loader has two configuration options.
- The layout to extend. Defaults to markdown.
- The block to override. Defaults to content.
Options can ether be a string or a function returning a string (called with the file path). Layout loader will check the following locations for configuration:
- A property call
options
on the loader object. - The loader object its self.
Examples
The following are valid configurations.
preLoaders: test: /\.md$/ loader: 'layout-loader' layout: 'my-layout'
preLoaders: test: /\.md$/ loader: 'layout-loader' 'bingo'
preLoaders: test: /\.md$/ loader: 'layout-loader' options: layout: 'layout' block: 'text'
Using with front matter
Layout Load was primarily built to be used with spike-front-matter. Here is how to integrate the two.
Option 1
const FrontMatter = let fm = moduleexports = { return defaults: } plugins: fm matchers: html: '**/*.(md|jade)' module: preLoaders: test: /\.md$/ loader: 'layout-loader' options: fmpage layout: 'default'
Option 2
const FrontMatter = let fm = moduleexports = { return defaults: } plugins: fm matchers: html: '**/*.(md|jade)' module: preLoaders: test: /\.md$/ loader: 'layout-loader' fmpagelayout