新增 /contact 联系我们页面
- types/wagtail.ts 新增 ContactPageDetail(与 HomePageDetail 同构)。 - services/page.service.ts 新增 getContactPage()。 - services/preview.service.ts 的 PREVIEW_PATH_RESOLVERS 新增 core.contactpage -> /contact。 - 新建 app/contact/page.tsx(generateMetadata + getPreviewOrFallback + BlockRenderer,与首页同构,未配置内容时展示友好提示而非 404)。
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { fetchAPI } from "./api-client";
|
||||
import type { HomePageDetail, WagtailListResponse } from "@/types/wagtail";
|
||||
import type { ContactPageDetail, HomePageDetail, WagtailListResponse } from "@/types/wagtail";
|
||||
|
||||
/**
|
||||
* 获取首页内容(取页面树中第一条 home.HomePage)。
|
||||
@@ -11,3 +11,14 @@ export async function getHomePage(): Promise<HomePageDetail | null> {
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取联系我们页面(apps.core.ContactPage,slug=contact)。
|
||||
*/
|
||||
export async function getContactPage(): Promise<ContactPageDetail | null> {
|
||||
const res = await fetchAPI<WagtailListResponse<ContactPageDetail>>(
|
||||
"/api/v2/pages/?type=core.ContactPage&fields=body,seo_title_override,seo_description_override&slug=contact&limit=1",
|
||||
{ tags: ["contact-page"] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ const PREVIEW_PATH_RESOLVERS: Record<
|
||||
"products.productpage": (page) => `/products/${page.meta.slug}`,
|
||||
"cases.casestudypage": (page) => `/cases/${page.meta.slug}`,
|
||||
"solutions.solutionpage": (page) => `/solutions/${page.meta.slug}`,
|
||||
"core.contactpage": () => "/contact",
|
||||
};
|
||||
|
||||
/** 根据 content_type 解析预览内容应跳转到的前端路径,未知类型返回 null。 */
|
||||
|
||||
Reference in New Issue
Block a user