Extract JSON front matter from strings and files in the style of Jekyll's YAML Front Matter.
parse( s )
Parses strings
, returning an object with propertiesattributes
, containing the JSON front matter, andbody
containing the rest.
var fm = require('json-front-matter');
var string = '{{{ "title" : "some title", "array" : [ 1, 2, 3 ] }}} bodybodybody';
var out = fm.parse( string );
console.log( out.body ) // 'bodybodybody'
console.log( out.attributes.title ) // 'some title'
console.log( out.attributes.array ) // [ 1, 2, 3 ]