Skip to content

Commit

Permalink
use each or forEach to loop categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrowe committed Mar 21, 2018
1 parent 2da3f8a commit 5b65b5b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/json_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ module.exports = function(locals){
});
temp_page.tags = tags
}
if (page.categories && page.categories.length > 0) {
var categories = new Array()
var cate_index = 0
page.categories.each(function (cate) {
categories[cate_index] = cate.name;
});
temp_page.categories = categories
if (post.categories && post.categories.length > 0) {
temp_post.categories = []
(post.categories.each || post.categories.forEach)(function (item) {
temp_post.categories.push(item)
});
}
res[index] = temp_page;
index += 1;
Expand Down

2 comments on commit 5b65b5b

@jamelt
Copy link

@jamelt jamelt commented on 5b65b5b Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seriously?

@wzpan
Copy link
Owner

@wzpan wzpan commented on 5b65b5b Mar 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamelt Yes it's a bug. Fixed.

Please sign in to comment.