mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: add missing posts sorting (#383)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user