https://github.com/willviles/broccoli-markdown-resolver
Broccoli plugin to recursively resolve .md files to a nested tree with parsing of content and frontmatter.
https://github.com/willviles/broccoli-markdown-resolver
broccoli broccoli-plugin frontmatter markdown resolver
Last synced: about 1 year ago
JSON representation
Broccoli plugin to recursively resolve .md files to a nested tree with parsing of content and frontmatter.
- Host: GitHub
- URL: https://github.com/willviles/broccoli-markdown-resolver
- Owner: willviles
- License: mit
- Created: 2017-09-12T16:24:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-31T17:42:47.000Z (over 7 years ago)
- Last Synced: 2025-03-18T14:53:50.294Z (about 1 year ago)
- Topics: broccoli, broccoli-plugin, frontmatter, markdown, resolver
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Broccoli Markdown Resolver
======
[](https://travis-ci.org/willviles/broccoli-markdown-resolver)  [](https://www.npmjs.com/package/broccoli-markdown-resolver)
Given an input node, Broccoli Markdown Resolver outputs a file exporting data for our .md files, with content and frontmatter parsed automatically.
## Installation
```
yarn add broccoli-markdown-resolver
```
## Usage
Consider the following folder structure inside our `inputNode`.
```shell
.
├── quick-start.md
├── sdks.md
└── sdks/
└── node-js.md
```
Run the resolver and choose an output destination.
```js
var MarkdownResolver = require('broccoli-markdown-resolver');
var outputNode = new MarkdownResolver(inputNodes, {
outputFile: '/markdown-file-data.js'
});
```
## Data
Require the data
```js
const markdownData = require('./path/to/markdown-file-data');
```
### markdownData.trees
Returns a tree of markdown data for each inputNode.
```js
{
"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
}
}
]
}
```
### markdownData.files
Returns a list of all files in a flat object format.
```js
[
{
"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
}
}
]
```