front-matter-loader
webpack loader to extract frontmatter using jxson/front-matter
Installation
npm install front-matter-loader
Usage
Given a file with frontmatter, e.g. example.md:
---title: Exampledescription: This is an example--- Here is some example content
The frontmatter can be extracted like this (using json-loader):
var exampleFrontmatter = ; console;// => 'Example'console;// => 'This is an example'console;// => 'Here is some example content'
To extract only the frontmatter attributes of the target file, use the onlyAttributes
query parameter:
var exampleAttributes = ;console;// => 'Example'console;// => 'This is an example'
To extract only the body content of the target file, use the onlyBody
query parameter:
var exampleContent = ;
For a complete example using a webpack config, see example/.