Skip to content

Commit a1e511e

Browse files
committed
Fix blog post ordering
1 parent f448e7c commit a1e511e

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/components/PostPagination.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function getNextPost() {
1616
for (const post of posts) {
1717
if (post.slug === slug) {
1818
postIndex = posts.indexOf(post);
19-
return posts[postIndex + 1];
19+
return posts[postIndex - 1];
2020
}
2121
}
2222
}
@@ -26,7 +26,7 @@ function getPrevPost() {
2626
for (const post of posts) {
2727
if (post.slug === slug) {
2828
postIndex = posts.indexOf(post);
29-
return posts[postIndex - 1];
29+
return posts[postIndex + 1];
3030
}
3131
}
3232
}

src/components/homepage/BlogPostsSection.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getActiveBlogPosts } from "src/util";
33
import CaretIcon from "src/components/ui/CaretIcon.astro";
44
5-
const posts = (await getActiveBlogPosts()).slice(-3).reverse();
5+
const posts = (await getActiveBlogPosts()).slice(0, 3);
66
---
77

88
<section class="bg-primary flex flex-col items-center px-4 py-10 text-white sm:px-6 lg:px-8" id="blog">

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function getActiveBlogPosts(): Promise<BlogPost[]> {
1717
export async function getAllBlogPosts(): Promise<BlogPost[]> {
1818
const posts = (await getCollection("blog"))
1919
.map((post) => parseBlogPost(post))
20-
.sort((a, b) => Temporal.ZonedDateTime.compare(a.date, b.date));
20+
.sort((a, b) => Temporal.ZonedDateTime.compare(b.date, a.date));
2121

2222
return posts;
2323
}

0 commit comments

Comments
 (0)