broca

frontmatter extractor

Usage no npm install needed!

<script type="module">
  import broca from 'https://cdn.skypack.dev/broca';
</script>

README

Broca Build Status

Lightweight (~450 bytes unminified) CSON frontmatter parser.

npm install broca

Broca's area

Usage

(pretending that Javascript has multiline strings)

var broca = require('broca');
var str = `
---
a: 1
b: 'hello'
c: [1, 2, 3]
---

hello world
`;

broca(str); //⇒ {a: 1, b:'hello', c:[1,2,3], body:'hello world'}

API

broca :: String → ∀ r. { body :: String | r }

Takes a string, returns an object containing at least a body, and whatever properties it parses from the frontmatter.

Licence

MIT. © 2014 Matt Brennan.