index.js
function createPost( file, options ) {

	resetDoc();

	var _formatDate = options && typeof options.formatDate === 'function' ?
				options.formatDate : formatDate,
			post = new Post();

	// Parse front matter to get as many post attributes as possible
	parseFrontMatter( file, post, options );

	// Get category from path if not from front matter
	if ( !post.category ) {

		post.category = getCategoryFromPath( file );
	}

	// Get creation date from file if not from front matter
	if ( !post.created ) {

		post.created = _formatDate( file.stat.ctime );
	}

	// Get excerpt from first <p> tag if not from front matter
	if ( !post.excerpt ) {

		post.excerpt = getDefaultExcerpt( post.content );
	}

	// Get title from file name if not from front matter
	if ( !post.title ) {

		post.title = getTitleFromPath( file );
	}

	// Get updated date from file if not from front matter
	if ( !post.updated ) {

		post.updated = _formatDate( file.stat.mtime );

		/*
		 * If updated date from file system matches creation date,
		 * assume udated date should be empty
		 */
		if ( post.updated === post.created ) {

			post.updated = '';
		}
	}

	return JSON.stringify( post );
}
function createPost( file, options ) {

	resetDoc();

	var _formatDate = options && typeof options.formatDate === 'function' ?
				options.formatDate : formatDate,
			post = new Post();

	// Parse front matter to get as many post attributes as possible
	parseFrontMatter( file, post, options );

	// Get category from path if not from front matter
	if ( !post.category ) {

		post.category = getCategoryFromPath( file );
	}

	// Get creation date from file if not from front matter
	if ( !post.created ) {

		post.created = _formatDate( file.stat.ctime );
	}

	// Get excerpt from first <p> tag if not from front matter
	if ( !post.excerpt ) {

		post.excerpt = getDefaultExcerpt( post.content );
	}

	// Get title from file name if not from front matter
	if ( !post.title ) {

		post.title = getTitleFromPath( file );
	}

	// Get updated date from file if not from front matter
	if ( !post.updated ) {

		post.updated = _formatDate( file.stat.mtime );

		/*
		 * If updated date from file system matches creation date,
		 * assume udated date should be empty
		 */
		if ( post.updated === post.created ) {

			post.updated = '';
		}
	}

	return JSON.stringify( post );
}
function createPost ( file , options ) { resetDoc ( ) ; var _formatDate = options && typeof options . formatDate === 'function' ? options . formatDate : formatDate , post = new Post ( ) ; // Parse front matter to get as many post attributes as possible parseFrontMatter ( file , post , options ) ; // Get category from path if not from front matter if ( ! post . category ) { post . category = getCategoryFromPath ( file ) ; } // Get creation date from file if not from front matter if ( ! post . created ) { post . created = _formatDate ( file . stat . ctime ) ; } // Get excerpt from first <p> tag if not from front matter if ( ! post . excerpt ) { post . excerpt = getDefaultExcerpt ( post . content ) ; } // Get title from file name if not from front matter if ( ! post . title ) { post . title = getTitleFromPath ( file ) ; } // Get updated date from file if not from front matter if ( ! post . updated ) { post . updated = _formatDate ( file . stat . mtime ) ; /*
		 * If updated date from file system matches creation date,
		 * assume udated date should be empty
		 */ if ( post . updated === post . created ) { post . updated = '' ; } } return JSON . stringify ( post ) ; }
Create a post object

@param {Object} file
@param {Object} [options]
@returns {string} post object as a string
Create a post object