Files
wagtailcms-frontend/services/page.service.ts
T
Zhengen 607dcdd660 新增 /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)。
2026-09-23 10:26:19 +08:00

25 lines
942 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { fetchAPI } from "./api-client";
import type { ContactPageDetail, HomePageDetail, WagtailListResponse } from "@/types/wagtail";
/**
* 获取首页内容(取页面树中第一条 home.HomePage)。
*/
export async function getHomePage(): Promise<HomePageDetail | null> {
const res = await fetchAPI<WagtailListResponse<HomePageDetail>>(
"/api/v2/pages/?type=home.HomePage&fields=body,seo_title_override,seo_description_override&limit=1",
{ tags: ["home-page"] },
);
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;
}