Given an input node, Broccoli Markdown Resolver outputs a file exporting data for our .md files, with content and frontmatter parsed automatically.
yarn add broccoli-markdown-resolver
Consider the following folder structure inside our inputNode
.
.
├── quick-start.md
├── sdks.md
└── sdks/
└── node-js.md
Run the resolver and choose an output destination.
var MarkdownResolver = require('broccoli-markdown-resolver');
var outputNode = new MarkdownResolver(inputNodes, {
outputFile: '/markdown-file-data.js'
});
Require the data
const markdownData = require('./path/to/markdown-file-data');
Returns a tree of markdown data for each inputNode.
{
"path/to/input-node": [
{
"path": "path/to/input-node/quick-start",
"content": "\nGet started quickly with Acme API.\n",
"attributes": {
"title": "Quick Start"
}
},
{
"path": "path/to/input-node/sdks",
"children": [
{
"path": "path/to/input-node/sdks/node-js",
"content": "\nAbout the Acme Node.js SDK.\n",
"attributes": {
"title": "Node.js SDK"
}
}
],
"content": "\nAcme offer SDKs in many different languages.\n",
"attributes": {
"title": "SDKs",
"custom-attr": true
}
}
]
}
Returns a list of all files in a flat object format.
[
{
"path": "path/to/input-node/quick-start",
"content": "\nGet started quickly with Acme API.\n",
"attributes": {
"title": "Quick Start"
}
},
{
"path": "path/to/input-node/sdks/node-js",
"content": "\nAbout the Acme Node.js SDK.\n",
"attributes": {
"title": "Node.js SDK"
}
},
{
"path": "path/to/input-node/sdks",
"children": [
{
"path": "path/to/input-node/sdks/node-js",
"content": "\nAbout the Acme Node.js SDK.\n",
"attributes": {
"title": "Node.js SDK"
}
}
],
"content": "\nAcme offer SDKs in many different languages.\n",
"attributes": {
"title": "SDKs",
"custom-attr": true
}
}
]