hexo
Version:
A fast, simple & powerful blog framework, powered by Node.js.
27 lines (21 loc) • 699 B
JavaScript
module.exports = function(locals, render, callback){
var config = hexo.config,
route = hexo.route;
if (config.exclude_generator && config.exclude_generator.indexOf('post') > -1) return callback();
var arr = locals.posts.sort('date', -1).toArray(),
length = arr.length;
arr.forEach(function(post, i){
var layout = post.layout,
path = post.path;
if (!layout || layout === 'false'){
route.set(path, function(fn){
fn(null, post.content);
});
} else {
post.prev = i === 0 ? null : arr[i - 1];
post.next = i === length - 1 ? null : arr[i + 1];
render(path, [layout, 'post', 'page', 'index'], post);
}
});
callback();
};