lib/utils.js
function getMetaData (data) {
    if (typeof data !== 'string') {
        throw new MeowError ('data is not a string');
    }
    data = data || '';
    data = data.split('\n');

    if (('' + data[0]).trim() !== '<!--') {
        throw new MeowError ("Incorrect format : Missing '<!--' in the beginning of the file");
    }

    var index = 1, metaData = [], dataLen = data.length;

    while (index < dataLen  && ('' + data[index]).trim() !== '-->' ) {
        metaData.push(data[index]);
        index++;
    }

    if (index == dataLen) {
        throw new MeowError ("Incorrect format : Missing closing '-->' for metadata comment");
    }

    metaData = metaData.join('\n');
    metaData = yaml.parse(metaData);

    if (!metaData.tags || typeof metaData.tags !== 'string')
    {
        metaData.tags = '';
    }
    metaData.tags = metaData.tags.split(',');
    metaData.tags = _.map(metaData.tags, function (tag) { return tag.trim(); });

    if (!metaData.keywords || typeof metaData.keywords !== 'string')
    {
        metaData.keywords = '';
    }
    metaData.keywords = metaData.keywords.split(',');
    metaData.keywords = _.map(metaData.keywords, function (tag) { return tag.trim(); });

    return metaData;
}
function getMetaData (data) {
    if (typeof data !== 'string') {
        throw new MeowError ('data is not a string');
    }
    data = data || '';
    data = data.split('\n');

    if (('' + data[0]).trim() !== '<!--') {
        throw new MeowError ("Incorrect format : Missing '<!--' in the beginning of the file");
    }

    var index = 1, metaData = [], dataLen = data.length;

    while (index < dataLen  && ('' + data[index]).trim() !== '-->' ) {
        metaData.push(data[index]);
        index++;
    }

    if (index == dataLen) {
        throw new MeowError ("Incorrect format : Missing closing '-->' for metadata comment");
    }

    metaData = metaData.join('\n');
    metaData = yaml.parse(metaData);

    if (!metaData.tags || typeof metaData.tags !== 'string')
    {
        metaData.tags = '';
    }
    metaData.tags = metaData.tags.split(',');
    metaData.tags = _.map(metaData.tags, function (tag) { return tag.trim(); });

    if (!metaData.keywords || typeof metaData.keywords !== 'string')
    {
        metaData.keywords = '';
    }
    metaData.keywords = metaData.keywords.split(',');
    metaData.keywords = _.map(metaData.keywords, function (tag) { return tag.trim(); });

    return metaData;
}
function getMetaData ( data ) { if ( typeof data !== 'string' ) { throw new MeowError ( 'data is not a string' ) ; } data = data || '' ; data = data . split ( '\n' ) ; if ( ( '' + data [ 0 ] ) . trim ( ) !== '<!--' ) { throw new MeowError ( "Incorrect format : Missing '<!--' in the beginning of the file" ) ; } var index = 1 , metaData = [ ] , dataLen = data . length ; while ( index < dataLen && ( '' + data [ index ] ) . trim ( ) !== '-->' ) { metaData . push ( data [ index ] ) ; index ++ ; } if ( index == dataLen ) { throw new MeowError ( "Incorrect format : Missing closing '-->' for metadata comment" ) ; } metaData = metaData . join ( '\n' ) ; metaData = yaml . parse ( metaData ) ; if ( ! metaData . tags || typeof metaData . tags !== 'string' ) { metaData . tags = '' ; } metaData . tags = metaData . tags . split ( ',' ) ; metaData . tags = _ . map ( metaData . tags , function ( tag ) { return tag . trim ( ) ; } ) ; if ( ! metaData . keywords || typeof metaData . keywords !== 'string' ) { metaData . keywords = '' ; } metaData . keywords = metaData . keywords . split ( ',' ) ; metaData . keywords = _ . map ( metaData . keywords , function ( tag ) { return tag . trim ( ) ; } ) ; return metaData ; }
Retrieves metadata for a given meow format blog post. This metadata will further be cached into 'posts'.
@param data The meow format blog post; must be a string
@returns {Object}
Typical format would be :
{
title: (title)
published-date: (published-date)
tags: [tagArray]
}
Retrieves metadata for a given meow format blog post . This metadata will further be cached into posts .