

























Organize large registries with included registry.json files.
We've added support for include in registry.json.
Registry authors can now organize a large source registry across multiple
registry.json files and compose them with shadcn build.
registry.json
components
└── ui
├── button.tsx
├── input.tsx
└── registry.json
hooks
├── registry.json
├── use-media-query.ts
└── use-toggle.ts{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"name": "acme",
"homepage": "https://acme.com",
"include": [
"components/ui/registry.json",
"hooks/registry.json"
]
}Included registry.json files are valid registry files for composition and may
omit name and homepage. Only the root registry.json must define the
registry metadata.
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"items": [
{
"name": "button",
"type": "registry:ui",
"files": [
{
"path": "button.tsx",
"type": "registry:ui"
}
]
}
]
}shadcn build resolves included registries and writes a flattened
registry.json without include. Item file paths are preserved from the root
registry, so a file declared in components/ui/registry.json is written as
components/ui/button.tsx in the built registry item.
The shadcn/registry package also exports loadRegistry and
loadRegistryItem for dynamic registry routes.
import { loadRegistry } from "shadcn/registry"
export async function GET() {
const registry = await loadRegistry()
return Response.json(registry)
}import { loadRegistryItem } from "shadcn/registry"
export async function GET(
_: Request,
{ params }: { params: Promise<{ name: string }> }
) {
const { name } = await params
const item = await loadRegistryItem(name)
return Response.json(item)
}See the registry.json documentation and getting started guide for more details.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。