Skip to content

gnowoel/frontmatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(string);

The YAML frontmatter should be defined at the beginning of the string, within a pair of triple-dash lines. For example:

---
title: Welcome
---

Hello!

In this case, the parsed object would be:

{
  "data": {
    "title": "Welcome"
  },
  "content": "\nHello!\n"
}

For untrusted source, the safeLoad option should be used:

frontmatter(content, { safeLoad: true });

Tests

$ npm install
$ npm test

License

MIT

About

A simple YAML frontmatter parser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published