Files
shadcn-ui/apps/www/lib/blocks.ts
shadcn 05145e66d3 feat: refactor registry (#6071)
* feat(www): add login blocks

* chore(www): restructure for blocks

* chore: build registry

* chore: clean up chunks

* fix(www): chart categories

* feat(www): big registry refactor

* feat(www): update blocks

* feat: complex blocks

* fix: update schema

* feat: sync new-york and default

* fix: lint

* feat: move charts

* fix(www): code

* fix: src path

* chore: rebuild registry

* fix: screenshot

* fix: set new-york as default
2024-12-14 14:52:55 +04:00

31 lines
819 B
TypeScript

"use server"
import { z } from "zod"
import { Style } from "@/registry/registry-styles"
import { registryItemSchema } from "@/registry/schema"
export async function getAllBlockIds(
types: z.infer<typeof registryItemSchema>["type"][] = [
"registry:block",
"registry:internal",
],
categories: string[] = [],
style: Style["name"] = "new-york"
): Promise<string[]> {
const { Index } = await import("@/__registry__")
const index = z.record(registryItemSchema).parse(Index[style])
return Object.values(index)
.filter(
(block) =>
types.includes(block.type) &&
(categories.length === 0 ||
block.categories?.some((category) =>
categories.includes(category)
)) &&
!block.name.startsWith("chart-")
)
.map((block) => block.name)
}