1.0.2 • Published 10 years ago
spirit-files v1.0.2
Spirit Files
Summary
A file generator for the Spirit Core static file generator.
Syntax
Install Spirit Core .
npm install spirit-core
Directory structure
- "test"
- "src"
-"post.md"
- "dest"
var SpiritCore = require( 'spirit-core' ) ;
var config = {
"src" : "src" ,
"dest": "dest"
} ;
var spirit = new SpiritCore( "./test", config ) ;
var spiritData = spirit.getData( ) ;
var spiritFiles = spiritData.files ;
var fileKeys = Object.keys( spiritFiles ) ;
for ( var i = 0; i < fileKeys.length; i++ ) {
var fileName = fileKeys[ i ] ;
var fileData = spiritFiles[ fileName ] ;
var fileContent = fileData.buffer.toString( 'utf8' ) ;
console.log( fileContent ) ;
console.log( fileName ) ;
}
Output directory structure
- "test"
- "src"
-"post.md"
- "dest"
-"post.md"
Properties
spiritData.files
A Object
with relative file name String
key and the fileData Object
as the value. or relative file names to a fileData Object
.
spiritData.files[ "relativeFilePath" ].buffer
A node buffer of that files content
The file object is a direct representation of what will be written to the destination folder.
The file content will be written using the fileData's content
or buffer
property, with the content
property taking priority.
Handmade in San Francisco California by Alex Ray