mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-17 07:51:21 +08:00
feat: 修改分页大小以匹配全局配置
This commit is contained in:
@ -6,6 +6,7 @@ import { getAllPosts, getUniqueCategories } from "@/data/post";
|
|||||||
import PageLayout from "@/layouts/Base.astro";
|
import PageLayout from "@/layouts/Base.astro";
|
||||||
import { collectionDateSort } from "@/utils/date";
|
import { collectionDateSort } from "@/utils/date";
|
||||||
import type { GetStaticPaths, Page } from "astro";
|
import type { GetStaticPaths, Page } from "astro";
|
||||||
|
import { MAX_POSTS_PER_PAGE } from "@/utils/constant";
|
||||||
|
|
||||||
export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
||||||
const allPosts = await getAllPosts();
|
const allPosts = await getAllPosts();
|
||||||
@ -17,7 +18,7 @@ export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
|||||||
category === "未分类" ? !post.data.category : post.data.category === category
|
category === "未分类" ? !post.data.category : post.data.category === category
|
||||||
);
|
);
|
||||||
return paginate(filterPosts, {
|
return paginate(filterPosts, {
|
||||||
pageSize: 20,
|
pageSize: MAX_POSTS_PER_PAGE,
|
||||||
params: { category },
|
params: { category },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import { getAllPosts, getUniqueTags } from "@/data/post";
|
|||||||
import PageLayout from "@/layouts/Base.astro";
|
import PageLayout from "@/layouts/Base.astro";
|
||||||
import { collectionDateSort } from "@/utils/date";
|
import { collectionDateSort } from "@/utils/date";
|
||||||
import type { GetStaticPaths, Page } from "astro";
|
import type { GetStaticPaths, Page } from "astro";
|
||||||
|
import { MAX_CATEGORIES } from "@/utils/constant";
|
||||||
|
|
||||||
export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
||||||
const allPosts = await getAllPosts();
|
const allPosts = await getAllPosts();
|
||||||
@ -15,7 +16,7 @@ export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
|
|||||||
return uniqueTags.flatMap((tag) => {
|
return uniqueTags.flatMap((tag) => {
|
||||||
const filterPosts = sortedPosts.filter((post) => post.data.tags.includes(tag));
|
const filterPosts = sortedPosts.filter((post) => post.data.tags.includes(tag));
|
||||||
return paginate(filterPosts, {
|
return paginate(filterPosts, {
|
||||||
pageSize: 20,
|
pageSize: MAX_CATEGORIES,
|
||||||
params: { tag },
|
params: { tag },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user