spirit-front-matter
v1.0.1
Published
A front matter file parser extension for the spirit static file generator
Readme
Spirit Front Matter
Summary
A YAML and JSON front matter middleware for the Spirit Core
static file generator. Using the Gray Matter
front matter parser.
Installation
Install from npm.
npm install spirit-front-matterSyntax
Directory structure
> = Directory
- = File
> "example"
> "src"
- matter.txtIn matter.txt file.
---
foo : bar
---
// File Content var spiritCore = require( 'spirit-core' ) ;
var spiritFrontMatter = require( 'spirit-front-matter' ) ;
var config = {
frontMatter : {
deliminators : [ '---', '---' ]
}
} ;
var spirit = new SpiritCore( '.', config ) ;
var spiritData = spirit.getData( ) ;
var spiritFiles = spiritData.files ;
console.log( spiritFiles[ "matter.txt" ] ) ;Will log the fileData
{
buffer : [ Buffer ],
data : { foo : "bar" } ,
content : // utf8 encoded file contents
}Configuration
Front Matter configuration object should map to the frontMatter key and has the optional values.
config.frontMatter.deliminators : Array
Takes an Array of two Strings that will mark the characters to deliminate the chunk of data to parse.
will default to [ "---", "---" ].
Refer to the Grey Matter front matter parser for more information.
Hand made in San Francisco California by Alex Ray .
