KO
베타 번역

@core / blocks

1.0.0 ▾
인증됨MIT
GitHub

페이지 블록: 접근성 갖춘 15개 섹션(히어로, 가격, JSON-LD FAQ 등), 관리자 편집기, 확장 가능한 등록

코드파일 25개컨텍스트약 681토큰검사 통과

.genpmignore 적용 후 주입될 정확한 트리입니다. 고정 대상:

src/lib/blocks/core/faq.ts읽기 전용 · a255d6d
import { createElement as h } from 'react';
import { z } from 'zod';
import { defineBlock } from '../define.ts';
import { JsonLd, optText, Section, text } from '../parts.ts';

export const faq = defineBlock({
  type: 'faq',
  label: 'FAQ',
  icon: 'help',
  schema: z.object({
    title: optText(160),
    items: z.array(z.object({ question: text(300), answer: text(3000) })).min(1).max(50),
    structuredData: z.boolean().default(true),
  }),
  fields: [
    { name: 'title', label: 'Title', type: 'text' },
    {
      name: 'items',
      label: 'Questions',
      type: 'list',
      required: true,
      fields: [
        { name: 'question', label: 'Question', type: 'text', required: true },
        { name: 'answer', label: 'Answer', type: 'textarea', required: true },
      ],
    },
    { name: 'structuredData', label: 'Add FAQPage structured data', type: 'boolean' },
  ],
  defaults: () => ({ items: [{ question: 'Question?', answer: 'Answer.' }], structuredData: true }),
  Component: ({ data, ctx }) =>
    h(
      Section,
      { id: ctx.id, block: 'faq', title: data.title, ctx, label: 'FAQ' },
      data.items.map((it, i) => h('details', { key: i, className: 'blk-faq__item' }, h('summary', null, it.question), h('p', null, it.answer))),
      data.structuredData &&
        h(JsonLd, {
          data: {
            '@context': 'https://schema.org',
            '@type': 'FAQPage',
            mainEntity: data.items.map((it) => ({ '@type': 'Question', name: it.question, acceptedAnswer: { '@type': 'Answer', text: it.answer } })),
          },
        }),
    ),
});

@core/blocks 신고

패키지를 신고하려면 GitHub로 로그인하세요.