From 2a9a394c9bd953a76dea90ed2f863f79f5a887aa Mon Sep 17 00:00:00 2001 From: Kent Liao <2964556627@qq.com> Date: Fri, 16 Dec 2022 10:38:11 +0800 Subject: [PATCH] feat: archives in descending order by month (#2959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement #### What this PR does / why we need it: 优化归档页面数据排序,按月份降序 #### Which issue(s) this PR fixes: Fixes #2958 #### Special notes for your reviewer: /cc @halo-dev/sig-halo #### Does this PR introduce a user-facing change? ```release-note 归档数据按月降序 ``` --- .../java/run/halo/app/theme/finders/impl/PostFinderImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/app/theme/finders/impl/PostFinderImpl.java b/src/main/java/run/halo/app/theme/finders/impl/PostFinderImpl.java index eb20974b3..708e05907 100644 --- a/src/main/java/run/halo/app/theme/finders/impl/PostFinderImpl.java +++ b/src/main/java/run/halo/app/theme/finders/impl/PostFinderImpl.java @@ -264,12 +264,13 @@ public class PostFinderImpl implements PostFinder { // convert to archive year month value objects List monthArchives = monthPosts.entrySet() .stream() - .sorted(Map.Entry.comparingByKey()) .map(monthEntry -> PostArchiveYearMonthVo.builder() .posts(monthEntry.getValue()) .month(monthEntry.getKey()) .build() ) + .sorted( + Comparator.comparing(PostArchiveYearMonthVo::getMonth).reversed()) .toList(); return PostArchiveVo.builder() .year(String.valueOf(key))