feat: render CMS content fields and footer settings
This commit is contained in:
@@ -10,7 +10,7 @@ import type {
|
||||
*/
|
||||
export async function getBlogList(): Promise<BlogPageSummary[]> {
|
||||
const res = await fetchAPI<WagtailListResponse<BlogPageSummary>>(
|
||||
"/api/v2/pages/?type=blog.BlogPage&fields=intro,published_at&order=-published_at",
|
||||
"/api/v2/pages/?type=blog.BlogPage&fields=intro,published_at,cover_image,tags&order=-published_at",
|
||||
{ tags: ["blog-list"] },
|
||||
);
|
||||
return res.items;
|
||||
@@ -21,7 +21,7 @@ export async function getBlogList(): Promise<BlogPageSummary[]> {
|
||||
*/
|
||||
export async function getBlogBySlug(slug: string): Promise<BlogPageDetail | null> {
|
||||
const res = await fetchAPI<WagtailListResponse<BlogPageDetail>>(
|
||||
`/api/v2/pages/?type=blog.BlogPage&slug=${encodeURIComponent(slug)}&fields=body,intro,published_at&limit=1`,
|
||||
`/api/v2/pages/?type=blog.BlogPage&slug=${encodeURIComponent(slug)}&fields=body,intro,published_at,cover_image,tags&limit=1`,
|
||||
{ tags: [`blog:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
/** 获取客户案例列表(按发布时间倒序)。 */
|
||||
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",
|
||||
"/api/v2/pages/?type=cases.CaseStudyPage&fields=client_name,industry,published_at,summary,cover_image&order=-published_at",
|
||||
{ tags: ["case-study-list"] },
|
||||
);
|
||||
return res.items;
|
||||
@@ -19,7 +19,7 @@ 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`,
|
||||
`/api/v2/pages/?type=cases.CaseStudyPage&slug=${encodeURIComponent(slug)}&fields=body,client_name,industry,published_at,summary,cover_image&limit=1`,
|
||||
{ tags: [`case-study:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { fetchAPI } from "./api-client";
|
||||
import type { ContactPageDetail, HomePageDetail, WagtailListResponse } from "@/types/wagtail";
|
||||
import type { ColumnPageDetail, ContactPageDetail, HomePageDetail, WagtailListResponse } from "@/types/wagtail";
|
||||
|
||||
export async function getColumnPage(type: string, slug: string): Promise<ColumnPageDetail | null> {
|
||||
const query = new URLSearchParams({ type, slug, fields: "intro", limit: "1" });
|
||||
const res = await fetchAPI<WagtailListResponse<ColumnPageDetail>>(`/api/v2/pages/?${query}`);
|
||||
return res.items[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页内容(取页面树中第一条 home.HomePage)。
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
/** 获取产品列表。 */
|
||||
export async function getProductList(): Promise<ProductPageSummary[]> {
|
||||
const res = await fetchAPI<WagtailListResponse<ProductPageSummary>>(
|
||||
"/api/v2/pages/?type=products.ProductPage&fields=summary",
|
||||
"/api/v2/pages/?type=products.ProductPage&fields=summary,cover_image",
|
||||
{ tags: ["product-list"] },
|
||||
);
|
||||
return res.items;
|
||||
@@ -19,7 +19,7 @@ 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`,
|
||||
`/api/v2/pages/?type=products.ProductPage&slug=${encodeURIComponent(slug)}&fields=body,summary,cover_image&limit=1`,
|
||||
{ tags: [`product:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
/** 获取解决方案列表。 */
|
||||
export async function getSolutionList(): Promise<SolutionPageSummary[]> {
|
||||
const res = await fetchAPI<WagtailListResponse<SolutionPageSummary>>(
|
||||
"/api/v2/pages/?type=solutions.SolutionPage&fields=industry,summary",
|
||||
"/api/v2/pages/?type=solutions.SolutionPage&fields=industry,summary,cover_image",
|
||||
{ tags: ["solution-list"] },
|
||||
);
|
||||
return res.items;
|
||||
@@ -19,7 +19,7 @@ export async function getSolutionBySlug(
|
||||
slug: string,
|
||||
): Promise<SolutionPageDetail | null> {
|
||||
const res = await fetchAPI<WagtailListResponse<SolutionPageDetail>>(
|
||||
`/api/v2/pages/?type=solutions.SolutionPage&slug=${encodeURIComponent(slug)}&fields=body,industry,summary&limit=1`,
|
||||
`/api/v2/pages/?type=solutions.SolutionPage&slug=${encodeURIComponent(slug)}&fields=body,industry,summary,cover_image&limit=1`,
|
||||
{ tags: [`solution:${slug}`] },
|
||||
);
|
||||
return res.items[0] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user