mirror of
https://github.com/KivotosRailway/website.git
synced 2026-11-03 19:07:56 +09:00
Add solitude
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const moment = require('moment')
|
||||
|
||||
hexo.extend.helper.register('getArchiveLength', function (type) {
|
||||
if (type !== 'year' && type !== 'month') {
|
||||
type = 'year';
|
||||
}
|
||||
const posts = this.site.posts.sort('-date').data
|
||||
let archive = {}
|
||||
for (const post of posts) {
|
||||
const postdate = type === 'year' ? moment(post.date).format('YYYY') : moment(post.date).format('YYYY/MM');
|
||||
archive[postdate] = (archive[postdate] || 0) + 1;
|
||||
}
|
||||
return archive;
|
||||
});
|
||||
Reference in New Issue
Block a user