add static path generate

This commit is contained in:
DefectingCat
2023-05-19 09:16:05 +08:00
parent 7db51d51a7
commit cd124571cc
3 changed files with 17 additions and 15 deletions

View File

@ -1,10 +1,14 @@
import PostCard from 'app/blog/post-card';
import PostCardLoading from 'app/blog/post-card-loading';
import Pagination from 'components/rua/rua-pagination';
import { postLists, PostPerPage } from 'lib/posts';
import { getPostListPath, postLists, PostPerPage } from 'lib/posts';
import { notFound } from 'next/navigation';
import { Fragment, Suspense } from 'react';
export async function generateStaticParams() {
return await getPostListPath();
}
export default async function Page({ params }: { params: { page: string } }) {
const page = Number(params.page);
if (!page) notFound();
@ -36,4 +40,4 @@ export default async function Page({ params }: { params: { page: string } }) {
/>
</>
);
}
}

View File

@ -2,20 +2,24 @@ import rehypePrism from '@mapbox/rehype-prism';
import components from 'components/mdx/components';
import PostToc from 'components/post/post-toc';
import data from 'content/mdx-data';
import { readSinglePost } from 'lib/posts';
import { readSinglePost, allPostsPath } from 'lib/posts';
import { SingleToc, generateToc } from 'lib/utils';
import { compileMDX } from 'next-mdx-remote/rsc';
import dynamic from 'next/dynamic';
import { notFound } from 'next/navigation';
import rehypeSlug from 'rehype-slug';
import remarkGfm from 'remark-gfm';
import { Post } from 'types';
import dynamic from 'next/dynamic';
const PostCommnetLine = dynamic(
() => import('components/post/post-commnet-line')
);
const PostComment = dynamic(() => import('components/post/post-comment'));
export async function generateStaticParams() {
return await allPostsPath();
}
const Page = async ({
params,
}: {
@ -70,4 +74,4 @@ const Page = async ({
);
};
export default Page;
export default Page;