2020-03-25 12:27:44 +08:00
|
|
|
hexo.extend.helper.register('isInHomePaging', function (pagePath, route) {
|
2020-03-27 20:45:27 +08:00
|
|
|
if (pagePath.length > 5 && route === '/') {
|
2020-03-25 12:27:44 +08:00
|
|
|
return pagePath.slice(0, 5) === 'page/';
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-27 20:45:27 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
hexo.extend.helper.register('createNewArchivePosts', function (posts) {
|
|
|
|
const postList = [], postYearList = [];
|
|
|
|
posts.forEach(post => postYearList.push(post.date.year()));
|
2020-03-27 20:49:27 +08:00
|
|
|
Array.from(new Set(postYearList)).reverse().forEach(year => {
|
2020-03-27 20:45:27 +08:00
|
|
|
postList.push({
|
|
|
|
year: year,
|
|
|
|
postList: []
|
|
|
|
})
|
|
|
|
});
|
|
|
|
postList.forEach(item => {
|
|
|
|
posts.forEach(post => item.year === post.date.year() && item.postList.push(post))
|
|
|
|
});
|
2020-03-30 10:20:17 +08:00
|
|
|
postList.forEach(item => item.postList.sort((a, b) => b.date.unix() - a.date.unix()));
|
2020-03-27 20:45:27 +08:00
|
|
|
return postList;
|
2020-03-17 17:58:18 +08:00
|
|
|
});
|