function urlPathForPost(post, permalinks) {
    var output = '',
        tags = {
            year:   function () { return moment(post.published_at).format('YYYY'); },
            month:  function () { return moment(post.published_at).format('MM'); },
            day:    function () { return moment(post.published_at).format('DD'); },
            author: function () { return post.author.slug; },
            slug:   function () { return post.slug; },
            id:     function () { return post.id; }
        };

    if (post.page) {
        output += '/:slug/';
    } else {
        output += permalinks;
    }

    // replace tags like :slug or :year with actual values
    output = output.replace(/(:[a-z]+)/g, function (match) {
        if (_.has(tags, match.substr(1))) {
            return tags[match.substr(1)]();
        }
    });

    return output;
}
// - permalinks - a string containing the permalinks setting
a string containing the permalinks setting
a string containing the permalinks setting
function urlPathForPost(post, permalinks) {
    var output = '',
        tags = {
            year:   function () { return moment(post.published_at).format('YYYY'); },
            month:  function () { return moment(post.published_at).format('MM'); },
            day:    function () { return moment(post.published_at).format('DD'); },
            author: function () { return post.author.slug; },
            slug:   function () { return post.slug; },
            id:     function () { return post.id; }
        };
    if (post.page) {
        output += '/:slug/';
    } else {
        output += permalinks;
    }
    output = output.replace(/(:[a-z]+)/g, function (match) {
        if (_.has(tags, match.substr(1))) {
            return tags[match.substr(1)]();
        }
    });
    return output;
}
function urlPathForPost ( post , permalinks ) { var output = '' , tags = { year : function ( ) { return moment ( post . published_at ) . format ( 'YYYY' ) ; } , month : function ( ) { return moment ( post . published_at ) . format ( 'MM' ) ; } , day : function ( ) { return moment ( post . published_at ) . format ( 'DD' ) ; } , author : function ( ) { return post . author . slug ; } , slug : function ( ) { return post . slug ; } , id : function ( ) { return post . id ; } } ; if ( post . page ) { output += '/:slug/' ; } else { output += permalinks ; } output = output . replace ( / (:[a-z]+) / g , function ( match ) { if ( _ . has ( tags , match . substr ( 1 ) ) ) { return tags [ match . substr ( 1 ) ] ( ) ; } } ) ; return output ; }
permalinks - a string containing the permalinks setting
permalinks - a string containing the permalinks setting
// replace tags like :slug or :year with actual values