c24712003 avatar

content-block

創建和維護 CMS Content Block 組件

提供方 c24712003|开源

Content Block 開發技能

組件結構

每個 Content Block 包含:

  1. 組件類別 - 渲染和邏輯
  2. Schema - 屬性定義和預設值
  3. 翻譯 - i18n 標籤

標準模板

import { Component, Input } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'cms-block-name',
  standalone: true,
  imports: [CommonModule],
  template: `
    <section class="block-name" [class]="styles?.background?.color">
      <div class="container mx-auto px-4">
        <h2 class="text-3xl font-bold">{{ headline }}</h2>
        <!-- 內容 -->
      </div>
    </section>
  `
})
export class BlockNameComponent {
  @Input() headline = '';
  @Input() items: any[] = [];
  @Input() styles: any = {};

  static schema = {
    type: 'block-name',
    label: 'BLOCKS_BLOCK_NAME_LABEL',
    properties: {
      headline: {
        type: 'string',
        label: 'BLOCKS_HEADLINE',
        default: 'Headline'
      },
      items: {
        type: 'array',
        label: 'BLOCKS_ITEMS',
        itemSchema: {
          title: { type: 'string', default: '' },
          description: { type: 'text', default: '' }
        }
      }
    },
    styles: {
      background: {
        color: { type: 'select', options: ['bg-white', 'bg-gray-100', 'bg-primary'] }
      }
    }
  };
}

現有 Content Blocks

位置: client/src/app/features/content-blocks/

組件說明
hero-section首頁橫幅
feature-grid功能網格
stats-counter統計數字
testimonials客戶評價
case-study-showcase案例展示
contact-form聯絡表單

屬性類型

type說明編輯器
string短文字text input
text長文字textarea
number數字number input
boolean布林toggle
select選擇dropdown
array陣列array editor
image圖片media picker
content-block - 适用于 Claude Code 与 Cursor 的 AI 智能体 Skill | Agent Skills