markdown-ast-loader
v0.1.4
Published
A webpack loader for markdown with yaml front matter
Downloads
3
Maintainers
Readme
A webpack loader for Markdown files with optional front matter - that returns the markdown's AST.
Installation
npm install markdown-ast-loader
Usage
{
module: {
loaders: {
{test: /\.md$/, loader: 'markdown-ast-loader'},
]
}
}
The result of importing a markdown file will be a JavaScript object with
properties from the front matter (as parsed by [js-yaml-front-matter]) and a
ast
property containing the markdown AST.
For example
---
name: Mongo the Monkey
contact:
email: [email protected]
---
I LIKE TO EAT BANANAS
=====================
* Fat bananas
* Skinny bananas
* Whatever
Renders to
{
"name": "Mongo the Monkey",
"contact": null,
"email": "[email protected]",
"ast": [
{
"type": "heading",
"text": [
"I LIKE TO EAT BANANAS"
],
"level": 1,
"raw": "I LIKE TO EAT BANANAS"
},
{
"type": "list",
"body": [
{
"type": "listitem",
"text": [
"Fat bananas"
]
},
{
"type": "listitem",
"text": [
"Skinny bananas"
]
},
{
"type": "listitem",
"text": [
"Whatever"
]
}
],
"ordered": false
}
]
}