ZH
测试版翻译

@core / blocks

1.0.0 ▾
已验证MIT
GitHub

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

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

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

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

export const guarantee = defineBlock({
  type: 'guarantee',
  label: 'Guarantee',
  icon: 'shield',
  schema: z.object({ badge: optText(30), title: text(160), text: text(1000), termsHref: href, termsLabel: optText(60) }),
  fields: [
    { name: 'badge', label: 'Badge (e.g. "30 days")', type: 'text' },
    { name: 'title', label: 'Title', type: 'text', required: true },
    { name: 'text', label: 'Text', type: 'textarea', required: true, help: 'Never present the legal 2-year guarantee or 14-day withdrawal right as an extra.' },
    { name: 'termsHref', label: 'Terms link', type: 'url' },
    { name: 'termsLabel', label: 'Terms link text', type: 'text' },
  ],
  defaults: () => ({ title: 'Money-back guarantee', text: '…' }),
  Component: ({ data, ctx }) =>
    h(
      Section,
      { id: ctx.id, block: 'guarantee', title: data.title, ctx },
      data.badge && h('p', { className: 'blk-guarantee__badge' }, data.badge),
      h('p', null, data.text),
      data.termsHref && h('p', null, h('a', { href: data.termsHref }, data.termsLabel ?? 'Terms')),
    ),
});

举报 @core/blocks

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