Skip to content

Commit

Permalink
fix(categories,tags): revert behavior of locals.tags and locals.categ…
Browse files Browse the repository at this point in the history
…ories (hexojs#5388)
  • Loading branch information
uiolee authored and dimaslanjaka committed Oct 3, 2024
1 parent 98ea2fa commit 149e73f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,15 @@ class Hexo extends EventEmitter {
return db.model('Page').find(query);
});

locals.set('categories', () => db.model('Category'));
locals.set('categories', () => {
// Ignore categories with zero posts
return db.model('Category').filter(category => category.length);
});

locals.set('tags', () => db.model('Tag'));
locals.set('tags', () => {
// Ignore tags with zero posts
return db.model('Tag').filter(tag => tag.length);
});

locals.set('data', () => {
const obj = {};
Expand Down

0 comments on commit 149e73f

Please sign in to comment.