From 3401a090ab8ae2236e732bda7595137594098c07 Mon Sep 17 00:00:00 2001 From: AdrianGonz97 <31664583+AdrianGonz97@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:03:29 -0400 Subject: [PATCH] fix block import paths --- sites/docs/scripts/build-registry.ts | 9 +- sites/docs/scripts/registry-new.ts | 22 +---- sites/docs/src/__registry__/blocks.js | 128 +++++++++++++------------- 3 files changed, 76 insertions(+), 83 deletions(-) diff --git a/sites/docs/scripts/build-registry.ts b/sites/docs/scripts/build-registry.ts index 76eb12341..50522eb53 100644 --- a/sites/docs/scripts/build-registry.ts +++ b/sites/docs/scripts/build-registry.ts @@ -56,13 +56,18 @@ export const Blocks = { fs.writeFileSync(chunkPath, chunk.content, { encoding: "utf8" }); } + const isDir = !fs.existsSync( + path.resolve("src", "lib", "registry", style.name, "block", `${block.name}.svelte`) + ); + const blockFile = isDir ? `${block.name}/page.svelte` : `${block.name}.svelte`; + blocksIndex += ` "${block.name}": { name: "${block.name}", type: "${block.type}", chunks: [${chunks.map((chunk) => ` { name: "${chunk.name}", description: "${chunk.description}", container: { className: "${chunk.container.className}" }, raw: () => import("./chunks/${style.name}/${chunk.name}.svelte?raw").then((m) => m.default), component: () => import("./chunks/${style.name}/${chunk.name}.svelte").then((m) => m.default) }`)}], - component: () => import("../lib/registry/${style.name}/block/${block.name}.svelte").then((m) => m.default), - raw: () => import("../lib/registry/${style.name}/block/${block.name}.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/${style.name}/block/${blockFile}").then((m) => m.default), + raw: () => import("../lib/registry/${style.name}/block/${blockFile}?raw").then((m) => m.default), },`; } // end of style diff --git a/sites/docs/scripts/registry-new.ts b/sites/docs/scripts/registry-new.ts index 5ec932905..fb876b9bb 100644 --- a/sites/docs/scripts/registry-new.ts +++ b/sites/docs/scripts/registry-new.ts @@ -62,10 +62,7 @@ export async function buildRegistry() { } async function crawlUI(rootPath: string, style: RegistryStyle) { - const dir = fs.readdirSync(rootPath, { - recursive: true, - withFileTypes: true, - }); + const dir = fs.readdirSync(rootPath, { recursive: true, withFileTypes: true }); const uiRegistry: Registry = []; @@ -122,9 +119,7 @@ async function buildUIRegistry(componentPath: string, componentName: string, sty async function crawlExample(rootPath: string, style: RegistryStyle) { const type = `registry:example` as const; - const dir = fs.readdirSync(rootPath, { - withFileTypes: true, - }); + const dir = fs.readdirSync(rootPath, { withFileTypes: true }); const registry: Registry = []; @@ -161,10 +156,7 @@ async function crawlExample(rootPath: string, style: RegistryStyle) { } async function buildBlockRegistry(blockPath: string, blockName: string, style: RegistryStyle) { - const dir = fs.readdirSync(blockPath, { - withFileTypes: true, - recursive: true, - }); + const dir = fs.readdirSync(blockPath, { withFileTypes: true, recursive: true }); const files: RegistryItemFile[] = []; const dependencies = new Set(); @@ -205,9 +197,7 @@ async function buildBlockRegistry(blockPath: string, blockName: string, style: R async function crawlBlock(rootPath: string, style: RegistryStyle) { const type = `registry:block` as const; - const dir = fs.readdirSync(rootPath, { - withFileTypes: true, - }); + const dir = fs.readdirSync(rootPath, { withFileTypes: true }); const registry: Registry = []; @@ -255,9 +245,7 @@ async function crawlBlock(rootPath: string, style: RegistryStyle) { async function crawlHook(rootPath: string, style: RegistryStyle) { const type = `registry:hook` as const; - const dir = fs.readdirSync(rootPath, { - withFileTypes: true, - }); + const dir = fs.readdirSync(rootPath, { withFileTypes: true }); const registry: Registry = []; diff --git a/sites/docs/src/__registry__/blocks.js b/sites/docs/src/__registry__/blocks.js index dc9612167..d65bb811b 100644 --- a/sites/docs/src/__registry__/blocks.js +++ b/sites/docs/src/__registry__/blocks.js @@ -84,113 +84,113 @@ export const Blocks = { name: "login-01", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/login-01.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/login-01.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/login-01/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/login-01/page.svelte?raw").then((m) => m.default), }, "sidebar-01": { name: "sidebar-01", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-01.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-01.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-01/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-01/page.svelte?raw").then((m) => m.default), }, "sidebar-02": { name: "sidebar-02", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-02.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-02.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-02/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-02/page.svelte?raw").then((m) => m.default), }, "sidebar-03": { name: "sidebar-03", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-03.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-03.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-03/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-03/page.svelte?raw").then((m) => m.default), }, "sidebar-04": { name: "sidebar-04", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-04.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-04.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-04/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-04/page.svelte?raw").then((m) => m.default), }, "sidebar-05": { name: "sidebar-05", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-05.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-05.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-05/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-05/page.svelte?raw").then((m) => m.default), }, "sidebar-06": { name: "sidebar-06", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-06.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-06.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-06/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-06/page.svelte?raw").then((m) => m.default), }, "sidebar-07": { name: "sidebar-07", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-07.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-07.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-07/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-07/page.svelte?raw").then((m) => m.default), }, "sidebar-08": { name: "sidebar-08", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-08.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-08.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-08/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-08/page.svelte?raw").then((m) => m.default), }, "sidebar-09": { name: "sidebar-09", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-09.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-09.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-09/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-09/page.svelte?raw").then((m) => m.default), }, "sidebar-10": { name: "sidebar-10", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-10.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-10.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-10/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-10/page.svelte?raw").then((m) => m.default), }, "sidebar-11": { name: "sidebar-11", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-11.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-11.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-11/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-11/page.svelte?raw").then((m) => m.default), }, "sidebar-12": { name: "sidebar-12", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-12.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-12.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-12/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-12/page.svelte?raw").then((m) => m.default), }, "sidebar-13": { name: "sidebar-13", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-13.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-13.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-13/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-13/page.svelte?raw").then((m) => m.default), }, "sidebar-14": { name: "sidebar-14", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-14.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-14.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-14/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-14/page.svelte?raw").then((m) => m.default), }, "sidebar-15": { name: "sidebar-15", type: "registry:block", chunks: [], - component: () => import("../lib/registry/default/block/sidebar-15.svelte").then((m) => m.default), - raw: () => import("../lib/registry/default/block/sidebar-15.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/default/block/sidebar-15/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/default/block/sidebar-15/page.svelte?raw").then((m) => m.default), }, }, "new-york": { "authentication-01": { @@ -274,113 +274,113 @@ export const Blocks = { name: "login-01", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/login-01.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/login-01.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/login-01/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/login-01/page.svelte?raw").then((m) => m.default), }, "sidebar-01": { name: "sidebar-01", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-01.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-01.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-01/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-01/page.svelte?raw").then((m) => m.default), }, "sidebar-02": { name: "sidebar-02", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-02.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-02.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-02/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-02/page.svelte?raw").then((m) => m.default), }, "sidebar-03": { name: "sidebar-03", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-03.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-03.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-03/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-03/page.svelte?raw").then((m) => m.default), }, "sidebar-04": { name: "sidebar-04", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-04.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-04.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-04/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-04/page.svelte?raw").then((m) => m.default), }, "sidebar-05": { name: "sidebar-05", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-05.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-05.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-05/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-05/page.svelte?raw").then((m) => m.default), }, "sidebar-06": { name: "sidebar-06", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-06.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-06.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-06/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-06/page.svelte?raw").then((m) => m.default), }, "sidebar-07": { name: "sidebar-07", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-07.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-07.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-07/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-07/page.svelte?raw").then((m) => m.default), }, "sidebar-08": { name: "sidebar-08", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-08.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-08.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-08/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-08/page.svelte?raw").then((m) => m.default), }, "sidebar-09": { name: "sidebar-09", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-09.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-09.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-09/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-09/page.svelte?raw").then((m) => m.default), }, "sidebar-10": { name: "sidebar-10", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-10.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-10.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-10/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-10/page.svelte?raw").then((m) => m.default), }, "sidebar-11": { name: "sidebar-11", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-11.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-11.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-11/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-11/page.svelte?raw").then((m) => m.default), }, "sidebar-12": { name: "sidebar-12", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-12.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-12.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-12/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-12/page.svelte?raw").then((m) => m.default), }, "sidebar-13": { name: "sidebar-13", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-13.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-13.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-13/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-13/page.svelte?raw").then((m) => m.default), }, "sidebar-14": { name: "sidebar-14", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-14.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-14.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-14/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-14/page.svelte?raw").then((m) => m.default), }, "sidebar-15": { name: "sidebar-15", type: "registry:block", chunks: [], - component: () => import("../lib/registry/new-york/block/sidebar-15.svelte").then((m) => m.default), - raw: () => import("../lib/registry/new-york/block/sidebar-15.svelte?raw").then((m) => m.default), + component: () => import("../lib/registry/new-york/block/sidebar-15/page.svelte").then((m) => m.default), + raw: () => import("../lib/registry/new-york/block/sidebar-15/page.svelte?raw").then((m) => m.default), }, }, };