lib/poet/utils.js
function createPost (filePath, options) {
  var fileName = path.basename(filePath);
  return fs.readFile(filePath, 'utf-8').then(function (data) {
    var parsed = (options.metaFormat === 'yaml' ? yamlFm : jsonFm)(data);
    var body = parsed.body;
    var post = parsed.attributes;
    // If no date defined, create one for current date
    post.date = new Date(post.date);
    post.content = body;
    // url slug for post
    post.slug = convertStringToSlug(post.slug || post.title);
    post.url = createURL(getRoute(options.routes, 'post'), post.slug);
    post.preview = getPreview(post, body, options);
    return post;
  });
}
function createPost (filePath, options) {
  var fileName = path.basename(filePath);
  return fs.readFile(filePath, 'utf-8').then(function (data) {
    var parsed = (options.metaFormat === 'yaml' ? yamlFm : jsonFm)(data);
    var body = parsed.body;
    var post = parsed.attributes;
    // If no date defined, create one for current date
    post.date = new Date(post.date);
    post.content = body;
    // url slug for post
    post.slug = convertStringToSlug(post.slug || post.title);
    post.url = createURL(getRoute(options.routes, 'post'), post.slug);
    post.preview = getPreview(post, body, options);
    return post;
  });
}
function createPost ( filePath , options ) { var fileName = path . basename ( filePath ) ; return fs . readFile ( filePath , 'utf-8' ) . then ( function ( data ) { var parsed = ( options . metaFormat === 'yaml' ? yamlFm : jsonFm ) ( data ) ; var body = parsed . body ; var post = parsed . attributes ; // If no date defined, create one for current date post . date = new Date ( post . date ) ; post . content = body ; // url slug for post post . slug = convertStringToSlug ( post . slug || post . title ) ; post . url = createURL ( getRoute ( options . routes , 'post' ) , post . slug ) ; post . preview = getPreview ( post , body , options ) ; return post ; } ) ; }
Accepts a name of a file and an options hash and returns an object
representing a post object

@params {String} data
@params {String} fileName
@params {Object} options
@returns {Object}
Accepts a name of a file and an options hash and returns an object representing a post object