gray-matter
Version:
A simple to use YAML, JSON or Coffee Front-Matter parsing and extraction library, with options to set custom delimiters.
43 lines (30 loc) • 647 B
Markdown
```js
var yfm = require('yfm');
yfm(String, Object);
```
# Methods
## yfm
By default the `yfm()` method expects a string. So this:
```js
yfm('---\nTitle: This is YFM\n---\n<p>This is content.<p>');
```
results in:
```json
{
"context": {
"title": "This is YFM"
},
"content": "<p>This is content.<p>",
"original": "---\nTitle: This is YFM\n---\n<p>This is content.<p>"
}
```
## yfm.read
To read a file from the file system before parsing, use `yfm.read`:
```js
yfm.read('file.md');
```
## yfm.exists
To check for YAML front matter, returning `true` or `false` if it exists, use `yfm.exists`:
```js
yfm.exists('file.md');
```