Skip to content

Commit c9eae0c

Browse files
committed
sort posts in tag pages chronologically
1 parent c0eb80a commit c9eae0c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pages/tags/[tag].astro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ export async function getStaticPaths() {
88
];
99
1010
return uniqueTags.map((tag) => {
11-
const filteredPosts = allPosts.filter((post) =>
12-
post.frontmatter.tags.includes(tag)
13-
);
11+
const filteredPosts = allPosts
12+
.filter((post) => post.frontmatter.tags.includes(tag))
13+
.sort(
14+
(a, b) =>
15+
new Date(b.frontmatter.pubDate) - new Date(a.frontmatter.pubDate)
16+
);
1417
return {
1518
params: { tag },
1619
props: { posts: filteredPosts },

0 commit comments

Comments
 (0)