Skip to content

Commit b6ebbca

Browse files
authored
fix(categories,tags): revert behavior of locals.tags and locals.categories (#5388)
1 parent 80dafe2 commit b6ebbca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/hexo/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,15 @@ class Hexo extends EventEmitter {
386386
return db.model('Page').find(query);
387387
});
388388

389-
locals.set('categories', () => db.model('Category'));
389+
locals.set('categories', () => {
390+
// Ignore categories with zero posts
391+
return db.model('Category').filter(category => category.length);
392+
});
390393

391-
locals.set('tags', () => db.model('Tag'));
394+
locals.set('tags', () => {
395+
// Ignore tags with zero posts
396+
return db.model('Tag').filter(tag => tag.length);
397+
});
392398

393399
locals.set('data', () => {
394400
const obj = {};

0 commit comments

Comments
 (0)