index.js
function getCategoryFromPath( file ) {

	var category = '',
			i = 0,
			parts = file.path.split('/'),
			len = parts.length,
			last = len - 1;

	for ( ; i < len; i++ ) {

		/*
		 * If previous path part is "posts" and the
		 * current path part isn't the last path part
		 */
		if ( parts[i - 1] === 'posts' && i !== last ) {

			category = parts[i];

			break;
		}
	}

	return category;
}
function getCategoryFromPath( file ) {

	var category = '',
			i = 0,
			parts = file.path.split('/'),
			len = parts.length,
			last = len - 1;

	for ( ; i < len; i++ ) {

		/*
		 * If previous path part is "posts" and the
		 * current path part isn't the last path part
		 */
		if ( parts[i - 1] === 'posts' && i !== last ) {

			category = parts[i];

			break;
		}
	}

	return category;
}
function getCategoryFromPath ( file ) { var category = '' , i = 0 , parts = file . path . split ( '/' ) , len = parts . length , last = len - 1 ; for ( ; i < len ; i ++ ) { /*
		 * If previous path part is "posts" and the
		 * current path part isn't the last path part
		 */ if ( parts [ i - 1 ] === 'posts' && i !== last ) { category = parts [ i ] ; break ; } } return category ; }
Get post category from file path

@param {Object} file
@returns {string}
Get post category from file path