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
  • Loading branch information
uiolee committed Dec 28, 2023
1 parent f5e0f92 commit 51540b7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/hexo/index.ts
Expand Up @@ -294,9 +294,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 51540b7

Please sign in to comment.