feat: 补全剩余 6 个 StreamField Block 前端渲染 (ProductCard/Pricing/Timeline/Team/TechStack/Video)
- types/wagtail.ts 新增对应 6 个 Block 值类型接口及 StreamFieldBlock 联合类型分支 - 新建 6 个渲染组件:ProductCardGrid/Pricing/Timeline/Team/TechStack/Video,风格与既有 Block 一致 - BlockRenderer.tsx 映射表接入新组件,key 与后端 COMMON_BLOCKS 保持一致 - lint/build 均验证通过
This commit is contained in:
@@ -7,13 +7,19 @@ import CTA from "./cta/CTA";
|
||||
import LogoCloud from "./logo-cloud/LogoCloud";
|
||||
import CaseStudyCard from "./case-study/CaseStudyCard";
|
||||
import LeadForm from "./form/LeadForm";
|
||||
import ProductCardGrid from "./product-card/ProductCardGrid";
|
||||
import Pricing from "./pricing/Pricing";
|
||||
import Timeline from "./timeline/Timeline";
|
||||
import Team from "./team/Team";
|
||||
import TechStack from "./tech-stack/TechStack";
|
||||
import Video from "./video/Video";
|
||||
import type { StreamFieldBlock } from "@/types/wagtail";
|
||||
|
||||
/**
|
||||
* StreamField 类型 → 组件映射表。
|
||||
* 必须与后端 apps/core/blocks.py 的 COMMON_BLOCKS 保持一致,
|
||||
* 否则新增/重命名 Block 时前后端会出现字段不对齐问题
|
||||
* (详见 documents/设计方案分析与完善版.md §2.6)。
|
||||
* (详见 documents/设计方案分析与完善版.md §2.6)。
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const components: Record<string, ComponentType<{ value: any }>> = {
|
||||
@@ -25,6 +31,12 @@ const components: Record<string, ComponentType<{ value: any }>> = {
|
||||
logo_cloud: LogoCloud,
|
||||
case_study: CaseStudyCard,
|
||||
form: LeadForm,
|
||||
product_card: ProductCardGrid,
|
||||
pricing: Pricing,
|
||||
timeline: Timeline,
|
||||
team: Team,
|
||||
tech_stack: TechStack,
|
||||
video: Video,
|
||||
};
|
||||
|
||||
export function BlockRenderer({ blocks }: { blocks: StreamFieldBlock[] }) {
|
||||
|
||||
Reference in New Issue
Block a user