From cb850a85c9abfad32ad98d5d9d30f162794918a8 Mon Sep 17 00:00:00 2001 From: longjuan <769022681@qq.com> Date: Mon, 16 Jan 2023 19:44:14 -0600 Subject: [PATCH] improve the sorting rules of archives by using reverse year order (#3158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /area core #### What this PR does / why we need it: Display archives in reverse chronological order. #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3157 #### Special notes for your reviewer: 改进前: ![image](https://user-images.githubusercontent.com/28662535/212591149-68683249-76a4-4cba-8b02-9a58901709ec.png) 改进后: ![image](https://user-images.githubusercontent.com/28662535/212591100-2c155cb7-832f-4c19-96bd-b783810138ce.png) #### Does this PR introduce a user-facing change? ```release-note 归档以年份降序排序 ``` --- .../java/run/halo/app/theme/finders/impl/PostFinderImpl.java | 4 +++- 1 file changed, 3 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 fc0eddfc4..874ba2c11 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 @@ -276,7 +276,9 @@ public class PostFinderImpl implements PostFinder { .year(String.valueOf(key)) .months(monthArchives) .build(); - }).toList(); + }) + .sorted(Comparator.comparing(PostArchiveVo::getYear).reversed()) + .toList(); return new ListResult<>(list.getPage(), list.getSize(), list.getTotal(), postArchives); })