fix: add missing posts sorting (#383)

This commit is contained in:
Rob Hudson
2024-10-02 07:31:12 -07:00
committed by GitHub
parent 9f878b53db
commit 94ede9bb17
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -3,10 +3,11 @@ import { SITE } from "@config";
import Posts from "@layouts/Posts.astro"; import Posts from "@layouts/Posts.astro";
import type { GetStaticPaths } from "astro"; import type { GetStaticPaths } from "astro";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import getSortedPosts from "@utils/getSortedPosts";
export const getStaticPaths = (async ({ paginate }) => { export const getStaticPaths = (async ({ paginate }) => {
const posts = await getCollection("blog", ({ data }) => !data.draft); const posts = await getCollection("blog", ({ data }) => !data.draft);
return paginate(posts, { pageSize: SITE.postPerPage }); return paginate(getSortedPosts(posts), { pageSize: SITE.postPerPage });
}) satisfies GetStaticPaths; }) satisfies GetStaticPaths;
const { page } = Astro.props; const { page } = Astro.props;
+2 -1
View File
@@ -3,10 +3,11 @@ import { SITE } from "@config";
import Posts from "@layouts/Posts.astro"; import Posts from "@layouts/Posts.astro";
import type { GetStaticPaths } from "astro"; import type { GetStaticPaths } from "astro";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import getSortedPosts from "@utils/getSortedPosts";
export const getStaticPaths = (async ({ paginate }) => { export const getStaticPaths = (async ({ paginate }) => {
const posts = await getCollection("blog", ({ data }) => !data.draft); const posts = await getCollection("blog", ({ data }) => !data.draft);
return paginate(posts, { pageSize: SITE.postPerPage }); return paginate(getSortedPosts(posts), { pageSize: SITE.postPerPage });
}) satisfies GetStaticPaths; }) satisfies GetStaticPaths;
const { page } = Astro.props; const { page } = Astro.props;