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 Apr 14, 2024
1 parent 80dafe2 commit b6ebbca
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 @@ -386,9 +386,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 b6ebbca

Please sign in to comment.