Skip to content

Commit

Permalink
fix: fix the archive page sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
xiecang committed Nov 18, 2024
1 parent 397e321 commit 01fc27b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/pages/archives/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,19 @@ const MonthMap: Record<string, string> = {
<sup class="text-xs">{monthGroup.length}</sup>
</div>
<ul>
{monthGroup.map(({ data, slug }) => (
<Card href={`/posts/${slug}`} frontmatter={data} />
))}
{monthGroup
.sort(
(a, b) =>
Math.floor(
new Date(b.data.pubDatetime).getTime() / 1000
) -
Math.floor(
new Date(a.data.pubDatetime).getTime() / 1000
)
)
.map(({ data, slug }) => (
<Card href={`/posts/${slug}`} frontmatter={data} />
))}
</ul>
</div>
))}
Expand Down

0 comments on commit 01fc27b

Please sign in to comment.