ZH
测试版翻译

@core / blocks

1.0.0 ▾
已验证MIT
GitHub

页面区块:15 个无障碍版块(首屏、价格、带 JSON-LD 的 FAQ 等)、后台编辑器和可扩展注册表

代码25 个文件上下文约 681 个 token扫描通过

应用 .genpmignore 后将被注入的确切目录树。固定于

src/lib/blocks/core/form.ts只读 · a255d6d
import { z } from 'zod';
import { createElement as h } from 'react';
import { defineBlock } from '../define.ts';
import { optText, Section, text } from '../parts.ts';

export const form = defineBlock({
  type: 'form',
  label: 'Form',
  icon: 'form',
  schema: z.object({ title: optText(160), intro: optText(400), formKey: text(60) }),
  fields: [
    { name: 'title', label: 'Title', type: 'text' },
    { name: 'intro', label: 'Introduction', type: 'textarea' },
    { name: 'formKey', label: 'Form', type: 'text', required: true, help: 'Key of a form defined with @core/forms (e.g. "contact").' },
  ],
  defaults: () => ({ formKey: 'contact' }),
  Component: ({ data, ctx }) => {
    const rendered = ctx.renderForm?.(data.formKey);
    if (!rendered) return null;
    return h(Section, { id: ctx.id, block: 'form', title: data.title, intro: data.intro, ctx, label: 'Form' }, rendered);
  },
});

举报 @core/blocks

使用 GitHub 登录后才能举报包。