registry.json 架构
完整架构
JSON
{
"$schema": "https://blockstudio.dev/schema/registry.json",
"name": "my-registry",
"description": "A collection of WordPress blocks.",
"baseUrl": "https://example.com/blocks",
"blocks": [
{
"name": "hero",
"title": "Hero",
"description": "Full-width hero section with heading and CTA.",
"category": "layout",
"type": "blockstudio",
"dependencies": ["button"],
"files": [
"block.json",
"index.php",
"style.scss"
]
}
]
}
顶层字段
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
$schema |
string |
否 | 用于编辑器验证的 JSON Schema URL。 |
name |
string |
是 | 注册表标识符。不得为空。 |
description |
string |
否 | 注册表的简短描述。 |
baseUrl |
string |
是 | 用于下载区块文件的基础 URL。必须是有效的 URL。 |
blocks |
BlockEntry[] |
是 | 可用区块数组。至少包含一项。 |
区块条目字段
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
name |
string |
是 | 区块文件夹名称和 CLI 标识符。不得为空。 |
title |
string |
否 | 供人阅读的显示名称。 |
description |
string |
否 | 搜索结果中显示的单行描述。 |
category |
string |
否 | 列表输出的分组标签。 |
type |
"blockstudio" | "create-block" | "wordpress" |
否 | 区块类型。仅供参考,不影响 CLI 行为。 |
dependencies |
string[] |
否 | 同一注册表中必须与此区块一同安装的区块名称。 |
files |
string[] |
是 | 相对于区块文件夹的文件路径。至少需要一个文件。 |
文件解析
每个文件都会从以下位置下载:
代码
{baseUrl}/{block.name}/{file}
并写入:
代码
{directory}/{block.name}/{file}
文件路径中的子目录会自动创建。
验证规则
- 在注册表和区块级别,
name都不能为空。 baseUrl必须是有效的 URL。blocks至少必须包含一项。- 每个区块的
files至少必须包含一项。 - 如果提供了
type,其值必须是三个允许值之一。 - 如果提供了
dependencies,它必须是字符串数组。每个依赖项都必须存在于同一注册表中,否则 CLI 会在解析时出错。