feat: add products/cases pages and lead-capture form block
- types: Product/CaseStudy page types, CaseStudyBlockValue, FormBlockValue - services: product.service.ts, case.service.ts - app/products, app/cases: list + detail pages - blocks: CaseStudyCard, LeadForm (submits to /api/v1/custom/leads/) - Header nav: add 产品/案例 links
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { fetchAPI } from "./api-client";
|
||||
import type {
|
||||
CaseStudyPageDetail,
|
||||
CaseStudyPageSummary,
|
||||
WagtailListResponse,
|
||||
} from "@/types/wagtail";
|
||||
|
||||
/** 获取客户案例列表(按发布时间倒序)。 */
|
||||
export async function getCaseStudyList(): Promise<CaseStudyPageSummary[]> {
|
||||
const res = await fetchAPI<WagtailListResponse<CaseStudyPageSummary>>(
|
||||
"/api/v2/pages/?type=cases.CaseStudyPage&fields=client_name,industry,published_at,summary&order=-published_at",
|
||||
{ tags: ["case-study-list"] },
|
||||
);
|
||||
return res.items;
|
||||
}
|
||||
|
||||
/** 根据 slug 获取客户案例详情。 */
|
||||
export async function getCaseStudyBySlug(
|
||||
slug: string,
|
||||
): Promise<CaseStudyPageDetail | null> {
|
||||
const res = await fetchAPI<WagtailListResponse<CaseStudyPageDetail>>(
|
||||
`/api/v2/pages/?type=cases.CaseStudyPage&slug=${encodeURIComponent(slug)}&fields=body,client_name,industry,published_at,summary&limit=1`,
|
||||
{ tags: [`case-study:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { fetchAPI } from "./api-client";
|
||||
import type {
|
||||
ProductPageDetail,
|
||||
ProductPageSummary,
|
||||
WagtailListResponse,
|
||||
} from "@/types/wagtail";
|
||||
|
||||
/** 获取产品列表。 */
|
||||
export async function getProductList(): Promise<ProductPageSummary[]> {
|
||||
const res = await fetchAPI<WagtailListResponse<ProductPageSummary>>(
|
||||
"/api/v2/pages/?type=products.ProductPage&fields=summary",
|
||||
{ tags: ["product-list"] },
|
||||
);
|
||||
return res.items;
|
||||
}
|
||||
|
||||
/** 根据 slug 获取产品详情。 */
|
||||
export async function getProductBySlug(
|
||||
slug: string,
|
||||
): Promise<ProductPageDetail | null> {
|
||||
const res = await fetchAPI<WagtailListResponse<ProductPageDetail>>(
|
||||
`/api/v2/pages/?type=products.ProductPage&slug=${encodeURIComponent(slug)}&fields=body,summary&limit=1`,
|
||||
{ tags: [`product:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
}
|
||||
Reference in New Issue
Block a user