fix: sort archive posts by pubDatetime (#415)

This commit is contained in:
xiecang
2025-01-02 16:40:30 +00:00
committed by GitHub
parent 63fe796eac
commit b9ef735d68
+11 -1
View File
@@ -59,7 +59,17 @@ const MonthMap: Record<string, string> = {
<sup class="text-xs">{monthGroup.length}</sup> <sup class="text-xs">{monthGroup.length}</sup>
</div> </div>
<ul> <ul>
{monthGroup.map(({ data, slug }) => ( {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} /> <Card href={`/posts/${slug}`} frontmatter={data} />
))} ))}
</ul> </ul>