Skip to content

Commit 113a186

Browse files
fix(demo): demo list generation, it should not add tsx endings
1 parent e01214f commit 113a186

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

lib/generate_demo_list/parts/serializeDemoComponentImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { join } from "node:path"
22

33
export function serializeDemoComponentImport(path: string, baseDir: string) {
4-
const name = path.split("/").at(-1)?.replace("", "")
4+
const name = path.split("/").at(-1)?.replace(/\.tsx?$/, "") || ""
55

66
const replacements = [
77
[join(baseDir, "src"), "@"],
8-
[join(baseDir, "lib"), "~"],
8+
[join(baseDir, "lib"), "~ui"],
99
] as const
1010

1111
let importPath = path

lib/generate_demo_list/parts/transformDemoListToRecord.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function transformDemoListToRecord(given: Record<string, string[]>): Reco
1010
if (!filename) continue
1111

1212
// Remove the .tsx extension
13-
const componentName = filename.replace("", "")
13+
const componentName = filename.replace(/\.tsx?$/, "")
1414

1515
// Map the component name to itself
1616
componentMap[componentName] = componentName
@@ -21,17 +21,4 @@ export function transformDemoListToRecord(given: Record<string, string[]>): Reco
2121

2222
return result
2323
}
24-
25-
/*
26-
implement transformDemoListToRecord
27-
so that a given = { ui_input [ "./src/ui/input/DemosUiInput", "src/ui/input/select/DemoMultiSelect"]}
28-
29-
will be returned as
30-
31-
{
32-
ui_input: {
33-
DemosUiInput: "DemosUiInput",
34-
DemoMultiSelect: "DemoMultiSelect",
35-
}
36-
}
3724
*/

src/demos/demoList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { lazy } from "solid-js"
2-
import { type DemoListType } from "~ui/generate_demo_list/DemoListType.ts"
2+
import { type DemoListType } from "~ui/generate_demo_list/DemoListType"
33

44
const DemoTablePagination2 = lazy(async () => {
55
const c = await import("@/demos/table/DemoTablePagination2.tsx")

src/demos/generateDemoList.cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { generateDemoList } from "../../lib/generate_demo_list/generateDemoList"
1+
import { generateDemoList } from "~ui/generate_demo_list/generateDemoList"
22

33
// const got = await findDemoFilesRecursive("./src/")
44
// console.log(got)

0 commit comments

Comments
 (0)