Skip to content

Commit

Permalink
Fix post sorting on /posts/
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Sep 19, 2024
1 parent d89fb48 commit 8a94e86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/pages/posts/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { SITE } from "@config";
import Posts from "@layouts/Posts.astro";
import type { GetStaticPaths } from "astro";
import { getCollection } from "astro:content";
import getSortedPosts from "@utils/getSortedPosts";
export const getStaticPaths = (async ({ paginate }) => {
const posts = await getCollection("blog", ({ data }) => !data.draft);
return paginate(posts, { pageSize: SITE.postPerPage });
return paginate(getSortedPosts(posts), { pageSize: SITE.postPerPage });
}) satisfies GetStaticPaths;
const { page } = Astro.props;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/posts/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { SITE } from "@config";
import Posts from "@layouts/Posts.astro";
import type { GetStaticPaths } from "astro";
import { getCollection } from "astro:content";
import getSortedPosts from "@utils/getSortedPosts";
export const getStaticPaths = (async ({ paginate }) => {
const posts = await getCollection("blog", ({ data }) => !data.draft);
return paginate(posts, { pageSize: SITE.postPerPage });
return paginate(getSortedPosts(posts), { pageSize: SITE.postPerPage });
}) satisfies GetStaticPaths;
const { page } = Astro.props;
Expand Down

0 comments on commit 8a94e86

Please sign in to comment.