JA
ベータ版の翻訳

@core / blocks

1.0.0 ▾
認証済みMIT
GitHub

ページブロック:アクセシブルな 15 セクション(ヒーロー、料金、JSON-LD 付き FAQ など)、管理エディタ、拡張可能な登録

コード25 ファイルコンテキスト約 681 トークンスキャン合格

.genpmignore 適用後に組み込まれる正確なツリーです。固定先:

src/lib/blocks/core/logos.ts読み取り専用 · a255d6d
import { createElement as h } from 'react';
import { z } from 'zod';
import { defineBlock } from '../define.ts';
import { href, Img, mediaId, optText, Section, text } from '../parts.ts';

export const logos = defineBlock({
  type: 'logos',
  label: 'Logos',
  icon: 'image',
  schema: z.object({
    title: optText(160),
    items: z.array(z.object({ name: text(100), image: mediaId, href })).min(1).max(24),
  }),
  fields: [
    { name: 'title', label: 'Title', type: 'text' },
    {
      name: 'items',
      label: 'Logos',
      type: 'list',
      required: true,
      fields: [
        { name: 'name', label: 'Name (used as alt text)', type: 'text', required: true },
        { name: 'image', label: 'Logo', type: 'media' },
        { name: 'href', label: 'Link', type: 'url' },
      ],
    },
  ],
  defaults: () => ({ items: [{ name: 'Company' }] }),
  Component: ({ data, ctx }) =>
    h(
      Section,
      { id: ctx.id, block: 'logos', title: data.title, ctx, label: 'Logos' },
      h(
        'ul',
        { className: 'blk-logos', role: 'list' },
        data.items.map((it, i) => {
          const img = ctx.image(it.image);
          const content = img ? h(Img, { image: img, alt: it.name }) : h('span', null, it.name);
          return h('li', { key: i }, it.href ? h('a', { href: it.href, rel: 'noopener noreferrer' }, content) : content);
        }),
      ),
    ),
});

@core/blocks を報告

パッケージを報告するには GitHub でログインしてください。

GitHub で続ける