|
|
@ -166,9 +166,7 @@ module.exports = function (Categories) {
|
|
|
|
var posts = [];
|
|
|
|
var posts = [];
|
|
|
|
getPostsRecursive(category, posts);
|
|
|
|
getPostsRecursive(category, posts);
|
|
|
|
|
|
|
|
|
|
|
|
posts.sort(function (a, b) {
|
|
|
|
posts.sort((a, b) => b.pid - a.pid);
|
|
|
|
return b.pid - a.pid;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (posts.length) {
|
|
|
|
if (posts.length) {
|
|
|
|
category.posts = [posts[0]];
|
|
|
|
category.posts = [posts[0]];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,9 +174,11 @@ module.exports = function (Categories) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getPostsRecursive(category, posts) {
|
|
|
|
function getPostsRecursive(category, posts) {
|
|
|
|
category.posts.forEach(function (p) {
|
|
|
|
if (Array.isArray(category.posts)) {
|
|
|
|
posts.push(p);
|
|
|
|
category.posts.forEach(function (p) {
|
|
|
|
});
|
|
|
|
posts.push(p);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
category.children.forEach(function (child) {
|
|
|
|
category.children.forEach(function (child) {
|
|
|
|
getPostsRecursive(child, posts);
|
|
|
|
getPostsRecursive(child, posts);
|
|
|
|