Skip to content

Commit

Permalink
fix block import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 committed Oct 22, 2024
1 parent e81ad1a commit 3401a09
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 83 deletions.
9 changes: 7 additions & 2 deletions sites/docs/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 5 additions & 17 deletions sites/docs/scripts/registry-new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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<string>();
Expand Down Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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 = [];

Expand Down
128 changes: 64 additions & 64 deletions sites/docs/src/__registry__/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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),
},
},
};

0 comments on commit 3401a09

Please sign in to comment.