From 291fa75c79c756a7a9fc84e44c2d3ab9331a41e7 Mon Sep 17 00:00:00 2001 From: moz Date: Sun, 25 Dec 2022 18:32:38 +0800 Subject: [PATCH] Fix date sorting issue Which mentioned [here](https://github.com/auroral-ui/hexo-theme-aurora/pull/224) --- scripts/lib/generators/category.js | 5 +++++ scripts/lib/generators/tag.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scripts/lib/generators/category.js b/scripts/lib/generators/category.js index baaec774..7442ba92 100644 --- a/scripts/lib/generators/category.js +++ b/scripts/lib/generators/category.js @@ -15,6 +15,11 @@ class CategoryGenerator { this.posts = posts this.configs = configs this.reduceCategories() + for(let cat of this.data) { + cat.data.postlist.sort(function (a, b) { + return a.date< b.date? 1 : -1; + }) + } } addCategories(data) { diff --git a/scripts/lib/generators/tag.js b/scripts/lib/generators/tag.js index dcbb8c99..428e78cb 100644 --- a/scripts/lib/generators/tag.js +++ b/scripts/lib/generators/tag.js @@ -15,6 +15,11 @@ class TagGenerator { this.posts = posts this.configs = configs this.reduceTags() + for(let cat of this.data) { + cat.data.postlist.sort(function (a, b) { + return a.date< b.date? 1 : -1; + }) + } } reduceTags() {