frontmatter

0.0.3 • Public • Published

frontmatter Build Status

A simple YAML frontmatter parser.

Installation

$ npm install frontmatter

Usage

To parse the YAML frontmatter from a string:

var frontmatter = require('frontmatter');
var parsed = frontmatter(content);

As in Jekyll, the YAML frontmatter should be delimited with triple-dash lines and defined at the beginning. For example:

---
title: Welcome
---
 
Hello!

In this case, the parsed object would be:

{
  "data": {
    "title": "Welcome"
  },
  "content": "Hello!"
}

For untrusted source, the safeLoad option should be used:

frontmatter(content, { safeLoad: true });

Tests

$ npm install
$ npm test

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    2,220
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    2,220
  • 0.0.2
    0
  • 0.0.1
    1
  • 0.0.0
    1

Package Sidebar

Install

npm i frontmatter

Weekly Downloads

2,132

Version

0.0.3

License

MIT

Last publish

Collaborators

  • gnowoel