17 lines
648 B
TypeScript
17 lines
648 B
TypeScript
import { fetchAPI } from "./api-client";
|
|
import type { SimpleContentPageDetail, WagtailListResponse } from "@/types/wagtail";
|
|
|
|
/**
|
|
* 根据 slug 获取通用富文本内容页(apps.core.SimpleContentPage),
|
|
* 用于隐私政策、服务条款等法务/说明类页面。
|
|
*/
|
|
export async function getSimpleContentPageBySlug(
|
|
slug: string,
|
|
): Promise<SimpleContentPageDetail | null> {
|
|
const res = await fetchAPI<WagtailListResponse<SimpleContentPageDetail>>(
|
|
`/api/v2/pages/?type=core.SimpleContentPage&slug=${encodeURIComponent(slug)}&fields=body&limit=1`,
|
|
{ tags: [`legal-page:${slug}`] },
|
|
);
|
|
return res.items[0] ?? null;
|
|
}
|