refactor(blog-plugin): blog archive reverse ordering of posts (#9438)

This commit is contained in:
Sébastien Lorber 2023-10-24 12:24:43 +02:00 committed by GitHub
parent 911dfb46d7
commit f80e1bdb32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,7 +54,7 @@ function YearsSection({years}: {years: YearProp[]}) {
}
function listPostsByYears(blogPosts: readonly ArchiveBlogPost[]): YearProp[] {
const postsByYear = blogPosts.reduceRight((posts, post) => {
const postsByYear = blogPosts.reduce((posts, post) => {
const year = post.metadata.date.split('-')[0]!;
const yearPosts = posts.get(year) ?? [];
return posts.set(year, [post, ...yearPosts]);