refactor(about): 重构关于页面路由为静态路径
将关于页面的查询参数路由改为静态路径结构,如/about/company 更新i18n消息中的链接路径 添加新的[section]页面处理逻辑 优化静态生成参数和错误处理
This commit is contained in:
@@ -9,8 +9,6 @@ import { getTranslations } from "next-intl/server";
|
||||
|
||||
type Params = Promise<{ locale: string }>;
|
||||
|
||||
type SearchParams = { page?: string; category?: string };
|
||||
|
||||
type MetadataProps = {
|
||||
params: Params;
|
||||
};
|
||||
@@ -33,21 +31,21 @@ export async function generateMetadata({
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
searchParams,
|
||||
// searchParams,
|
||||
}: {
|
||||
params: Params;
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
const resolvedSearchParams = await searchParams;
|
||||
const category = resolvedSearchParams.category as string || "";
|
||||
// const resolvedSearchParams = await searchParams;
|
||||
// const category = resolvedSearchParams.category as string || "";
|
||||
|
||||
let { posts } = await getPosts(locale);
|
||||
|
||||
const t = await getTranslations("Blog");
|
||||
|
||||
const pageRaw = resolvedSearchParams.page as string || "1";
|
||||
const page = Math.max(1, parseInt(pageRaw, 10));
|
||||
// const pageRaw = resolvedSearchParams.page as string || "1";
|
||||
// const page = Math.max(1, parseInt(10, 10));
|
||||
const page = 1;
|
||||
const pageSize = 10;
|
||||
const totalPages = Math.max(1, Math.ceil(posts.length / pageSize));
|
||||
const start = (page - 1) * pageSize;
|
||||
|
||||
Reference in New Issue
Block a user