create-tsrouter-app 0.3.0-alpha.7 → 0.3.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/create-app.js +31 -11
- package/dist/options.js +3 -0
- package/package.json +1 -1
- package/src/create-app.ts +50 -18
- package/src/options.ts +4 -0
- package/templates/react/add-on/form/assets/src/routes/{demo.form.tsx → demo.form.tsx.ejs} +15 -3
- package/templates/react/add-on/form/info.json +1 -1
- package/templates/react/add-on/sentry/info.json +1 -1
- package/templates/react/add-on/store/assets/src/routes/{demo.store.page1.tsx → demo.store.page1.tsx.ejs} +14 -6
- package/templates/react/add-on/store/assets/src/routes/{demo.store.page2.tsx → demo.store.page2.tsx.ejs} +15 -6
- package/templates/react/add-on/store/info.json +1 -1
- package/templates/react/code-router/src/main.tsx.ejs +6 -1
- package/templates/solid/add-on/form/assets/src/routes/{demo.form.tsx → demo.form.tsx.ejs} +14 -2
- package/templates/solid/add-on/form/info.json +1 -1
- package/templates/solid/add-on/store/assets/src/routes/{demo.store.page1.tsx → demo.store.page1.tsx.ejs} +15 -4
- package/templates/solid/add-on/store/assets/src/routes/{demo.store.page2.tsx → demo.store.page2.tsx.ejs} +14 -5
- package/templates/solid/add-on/store/info.json +1 -1
- package/templates/solid/code-router/src/main.tsx.ejs +6 -1
- /package/templates/react/{file-router → base}/src/components/Header.tsx.ejs +0 -0
- /package/templates/solid/{file-router → base}/src/components/Header.tsx.ejs +0 -0
package/dist/create-app.js
CHANGED
|
@@ -26,7 +26,7 @@ function createCopyFiles(targetDir) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function createTemplateFile(projectName, options, targetDir) {
|
|
29
|
-
return async function templateFile(templateDir, file, targetFileName) {
|
|
29
|
+
return async function templateFile(templateDir, file, targetFileName, extraTemplateValues) {
|
|
30
30
|
const templateValues = {
|
|
31
31
|
packageManager: options.packageManager,
|
|
32
32
|
projectName: projectName,
|
|
@@ -41,6 +41,7 @@ function createTemplateFile(projectName, options, targetDir) {
|
|
|
41
41
|
return acc;
|
|
42
42
|
}, {}),
|
|
43
43
|
addOns: options.chosenAddOns,
|
|
44
|
+
...extraTemplateValues,
|
|
44
45
|
};
|
|
45
46
|
const template = await readFile(resolve(templateDir, file), 'utf-8');
|
|
46
47
|
let content = render(template, templateValues);
|
|
@@ -197,7 +198,6 @@ export async function createApp(options) {
|
|
|
197
198
|
copyFiles(templateDirBase, ['./src/logo.svg']);
|
|
198
199
|
// Setup the app component. There are four variations, typescript/javascript and tailwind/non-tailwind.
|
|
199
200
|
if (options.mode === FILE_ROUTER) {
|
|
200
|
-
await templateFile(templateDirRouter, './src/components/Header.tsx.ejs', './src/components/Header.tsx');
|
|
201
201
|
await templateFile(templateDirRouter, './src/routes/__root.tsx.ejs', './src/routes/__root.tsx');
|
|
202
202
|
await templateFile(templateDirBase, './src/App.tsx.ejs', './src/routes/index.tsx');
|
|
203
203
|
}
|
|
@@ -207,15 +207,6 @@ export async function createApp(options) {
|
|
|
207
207
|
await templateFile(templateDirBase, './src/App.test.tsx.ejs', options.typescript ? undefined : './src/App.test.jsx');
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
// Create the main entry point
|
|
211
|
-
if (!isAddOnEnabled('start')) {
|
|
212
|
-
if (options.typescript) {
|
|
213
|
-
await templateFile(templateDirRouter, './src/main.tsx.ejs');
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
await templateFile(templateDirRouter, './src/main.tsx.ejs', './src/main.jsx');
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
210
|
// Setup the main, reportWebVitals and index.html files
|
|
220
211
|
if (!isAddOnEnabled('start') && options.framework === 'react') {
|
|
221
212
|
if (options.typescript) {
|
|
@@ -268,6 +259,35 @@ export async function createApp(options) {
|
|
|
268
259
|
s.stop(`Installed shadcn components`);
|
|
269
260
|
}
|
|
270
261
|
}
|
|
262
|
+
const routes = [];
|
|
263
|
+
if (existsSync(resolve(targetDir, 'src/routes'))) {
|
|
264
|
+
for (const file of readdirSync(resolve(targetDir, 'src/routes'))) {
|
|
265
|
+
const name = file.replace(/\.tsx?|\.jsx?/, '');
|
|
266
|
+
routes.push({
|
|
267
|
+
path: `./routes/${name}`,
|
|
268
|
+
name: name
|
|
269
|
+
.split('.')
|
|
270
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
271
|
+
.join(''),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Create the main entry point
|
|
276
|
+
if (!isAddOnEnabled('start')) {
|
|
277
|
+
if (options.typescript) {
|
|
278
|
+
await templateFile(templateDirRouter, './src/main.tsx.ejs', './src/main.tsx', {
|
|
279
|
+
routes,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
await templateFile(templateDirRouter, './src/main.jsx.ejs', './src/main.jsx', {
|
|
284
|
+
routes,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (routes.length > 0) {
|
|
289
|
+
await templateFile(templateDirBase, './src/components/Header.tsx.ejs', './src/components/Header.tsx');
|
|
290
|
+
}
|
|
271
291
|
const warnings = [];
|
|
272
292
|
for (const addOn of options.chosenAddOns) {
|
|
273
293
|
if (addOn.warning) {
|
package/dist/options.js
CHANGED
|
@@ -71,6 +71,9 @@ export async function promptForOptions(cliOptions) {
|
|
|
71
71
|
options.typescript = true;
|
|
72
72
|
options.tailwind = true;
|
|
73
73
|
}
|
|
74
|
+
if (cliOptions.addOns) {
|
|
75
|
+
options.typescript = true;
|
|
76
|
+
}
|
|
74
77
|
if (!cliOptions.projectName) {
|
|
75
78
|
const value = await text({
|
|
76
79
|
message: 'What would you like to name your project?',
|
package/package.json
CHANGED
package/src/create-app.ts
CHANGED
|
@@ -50,6 +50,7 @@ function createTemplateFile(
|
|
|
50
50
|
templateDir: string,
|
|
51
51
|
file: string,
|
|
52
52
|
targetFileName?: string,
|
|
53
|
+
extraTemplateValues?: Record<string, any>,
|
|
53
54
|
) {
|
|
54
55
|
const templateValues = {
|
|
55
56
|
packageManager: options.packageManager,
|
|
@@ -68,6 +69,7 @@ function createTemplateFile(
|
|
|
68
69
|
{},
|
|
69
70
|
),
|
|
70
71
|
addOns: options.chosenAddOns,
|
|
72
|
+
...extraTemplateValues,
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
const template = await readFile(resolve(templateDir, file), 'utf-8')
|
|
@@ -300,11 +302,6 @@ export async function createApp(options: Required<Options>) {
|
|
|
300
302
|
|
|
301
303
|
// Setup the app component. There are four variations, typescript/javascript and tailwind/non-tailwind.
|
|
302
304
|
if (options.mode === FILE_ROUTER) {
|
|
303
|
-
await templateFile(
|
|
304
|
-
templateDirRouter,
|
|
305
|
-
'./src/components/Header.tsx.ejs',
|
|
306
|
-
'./src/components/Header.tsx',
|
|
307
|
-
)
|
|
308
305
|
await templateFile(
|
|
309
306
|
templateDirRouter,
|
|
310
307
|
'./src/routes/__root.tsx.ejs',
|
|
@@ -330,19 +327,6 @@ export async function createApp(options: Required<Options>) {
|
|
|
330
327
|
}
|
|
331
328
|
}
|
|
332
329
|
|
|
333
|
-
// Create the main entry point
|
|
334
|
-
if (!isAddOnEnabled('start')) {
|
|
335
|
-
if (options.typescript) {
|
|
336
|
-
await templateFile(templateDirRouter, './src/main.tsx.ejs')
|
|
337
|
-
} else {
|
|
338
|
-
await templateFile(
|
|
339
|
-
templateDirRouter,
|
|
340
|
-
'./src/main.tsx.ejs',
|
|
341
|
-
'./src/main.jsx',
|
|
342
|
-
)
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
330
|
// Setup the main, reportWebVitals and index.html files
|
|
347
331
|
if (!isAddOnEnabled('start') && options.framework === 'react') {
|
|
348
332
|
if (options.typescript) {
|
|
@@ -426,6 +410,54 @@ export async function createApp(options: Required<Options>) {
|
|
|
426
410
|
}
|
|
427
411
|
}
|
|
428
412
|
|
|
413
|
+
const routes: Array<{
|
|
414
|
+
path: string
|
|
415
|
+
name: string
|
|
416
|
+
}> = []
|
|
417
|
+
if (existsSync(resolve(targetDir, 'src/routes'))) {
|
|
418
|
+
for (const file of readdirSync(resolve(targetDir, 'src/routes'))) {
|
|
419
|
+
const name = file.replace(/\.tsx?|\.jsx?/, '')
|
|
420
|
+
routes.push({
|
|
421
|
+
path: `./routes/${name}`,
|
|
422
|
+
name: name
|
|
423
|
+
.split('.')
|
|
424
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
425
|
+
.join(''),
|
|
426
|
+
})
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Create the main entry point
|
|
431
|
+
if (!isAddOnEnabled('start')) {
|
|
432
|
+
if (options.typescript) {
|
|
433
|
+
await templateFile(
|
|
434
|
+
templateDirRouter,
|
|
435
|
+
'./src/main.tsx.ejs',
|
|
436
|
+
'./src/main.tsx',
|
|
437
|
+
{
|
|
438
|
+
routes,
|
|
439
|
+
},
|
|
440
|
+
)
|
|
441
|
+
} else {
|
|
442
|
+
await templateFile(
|
|
443
|
+
templateDirRouter,
|
|
444
|
+
'./src/main.jsx.ejs',
|
|
445
|
+
'./src/main.jsx',
|
|
446
|
+
{
|
|
447
|
+
routes,
|
|
448
|
+
},
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (routes.length > 0) {
|
|
454
|
+
await templateFile(
|
|
455
|
+
templateDirBase,
|
|
456
|
+
'./src/components/Header.tsx.ejs',
|
|
457
|
+
'./src/components/Header.tsx',
|
|
458
|
+
)
|
|
459
|
+
}
|
|
460
|
+
|
|
429
461
|
const warnings: Array<string> = []
|
|
430
462
|
for (const addOn of options.chosenAddOns) {
|
|
431
463
|
if (addOn.warning) {
|
package/src/options.ts
CHANGED
|
@@ -99,6 +99,10 @@ export async function promptForOptions(
|
|
|
99
99
|
options.tailwind = true
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
if (cliOptions.addOns) {
|
|
103
|
+
options.typescript = true
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
if (!cliOptions.projectName) {
|
|
103
107
|
const value = await text({
|
|
104
108
|
message: 'What would you like to name your project?',
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/react-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'
|
|
2
2
|
import { useForm } from '@tanstack/react-form'
|
|
3
3
|
|
|
4
|
+
<% if (codeRouter) { %>
|
|
5
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
6
|
+
<% } else { %>
|
|
4
7
|
export const Route = createFileRoute('/demo/form')({
|
|
5
|
-
component:
|
|
8
|
+
component: FormDemo,
|
|
6
9
|
})
|
|
10
|
+
<% } %>
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
function FormDemo() {
|
|
9
13
|
const form = useForm({
|
|
10
14
|
defaultValues: {
|
|
11
15
|
fullName: '',
|
|
@@ -48,3 +52,11 @@ export default function App() {
|
|
|
48
52
|
</div>
|
|
49
53
|
)
|
|
50
54
|
}
|
|
55
|
+
|
|
56
|
+
<% if (codeRouter) { %>
|
|
57
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
58
|
+
path: '/demo/form',
|
|
59
|
+
component: FormDemo,
|
|
60
|
+
getParentRoute: () => parentRoute,
|
|
61
|
+
})
|
|
62
|
+
<% } %>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"phase": "setup",
|
|
4
4
|
"description": "Add Sentry for error monitoring, tracing, and session replays (requires Start).",
|
|
5
5
|
"link": "https://sentry.com/",
|
|
6
|
-
"templates": ["file-router"],
|
|
6
|
+
"templates": ["file-router", "code-router"],
|
|
7
7
|
"routes": [
|
|
8
8
|
{
|
|
9
9
|
"url": "/demo/sentry/testing",
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/react-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'
|
|
2
2
|
import { useStore } from '@tanstack/react-store'
|
|
3
3
|
|
|
4
4
|
import { store } from '../lib/demo-store'
|
|
5
|
-
|
|
5
|
+
<% if (codeRouter) { %>
|
|
6
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
7
|
+
<% } else { %>
|
|
6
8
|
export const Route = createFileRoute('/demo/store/page1')({
|
|
7
|
-
component:
|
|
9
|
+
component: StorePage1,
|
|
8
10
|
})
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
+
<% } %>
|
|
12
|
+
function StorePage1() {
|
|
11
13
|
const count = useStore(store, (state) => state.count)
|
|
12
14
|
|
|
13
15
|
return (
|
|
@@ -27,4 +29,10 @@ function App() {
|
|
|
27
29
|
)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
<% if (codeRouter) { %>
|
|
33
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
34
|
+
path: '/demo/store/page1',
|
|
35
|
+
component: StorePage1,
|
|
36
|
+
getParentRoute: () => parentRoute,
|
|
37
|
+
})
|
|
38
|
+
<% } %>
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/react-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'
|
|
2
2
|
import { useStore } from '@tanstack/react-store'
|
|
3
3
|
|
|
4
4
|
import { store } from '../lib/demo-store'
|
|
5
|
-
|
|
5
|
+
<% if (codeRouter) { %>
|
|
6
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
7
|
+
<% } else { %>
|
|
6
8
|
export const Route = createFileRoute('/demo/store/page2')({
|
|
7
|
-
component:
|
|
9
|
+
component: StorePage2,
|
|
8
10
|
})
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
+
<% } %>
|
|
12
|
+
function StorePage2() {
|
|
11
13
|
const count = useStore(store, (state) => state.count)
|
|
12
14
|
|
|
13
15
|
return (
|
|
@@ -27,4 +29,11 @@ function App() {
|
|
|
27
29
|
)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
<% if (codeRouter) { %>
|
|
33
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
34
|
+
path: '/demo/store/page2',
|
|
35
|
+
component: StorePage2,
|
|
36
|
+
getParentRoute: () => parentRoute,
|
|
37
|
+
})
|
|
38
|
+
<% } %>
|
|
39
|
+
|
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
createRouter,
|
|
9
9
|
} from "@tanstack/react-router";
|
|
10
10
|
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
|
11
|
+
<% for(const route of routes) { %>import <%= route.name %> from "<%= route.path %>";
|
|
12
|
+
<% } %><% if (routes.length > 0) { %>
|
|
13
|
+
import Header from "./components/Header";
|
|
14
|
+
<% } %>
|
|
11
15
|
|
|
12
16
|
import "./styles.css";
|
|
13
17
|
import reportWebVitals from "./reportWebVitals.<%= js %>";
|
|
@@ -17,6 +21,7 @@ import App from "./App.<%= jsx %>";
|
|
|
17
21
|
const rootRoute = createRootRoute({
|
|
18
22
|
component: () => (
|
|
19
23
|
<>
|
|
24
|
+
<% if (routes.length > 0) { %><Header /><% } %>
|
|
20
25
|
<Outlet />
|
|
21
26
|
<TanStackRouterDevtools />
|
|
22
27
|
</>
|
|
@@ -29,7 +34,7 @@ const indexRoute = createRoute({
|
|
|
29
34
|
component: App,
|
|
30
35
|
});
|
|
31
36
|
|
|
32
|
-
const routeTree = rootRoute.addChildren([indexRoute]);
|
|
37
|
+
const routeTree = rootRoute.addChildren([indexRoute<%= routes.map(route => `, ${route.name}(rootRoute)`).join('') %>]);
|
|
33
38
|
|
|
34
39
|
const router = createRouter({
|
|
35
40
|
routeTree,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/solid-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/solid-router'
|
|
2
2
|
|
|
3
3
|
import { createForm } from '@tanstack/solid-form'
|
|
4
4
|
import type { AnyFieldApi } from '@tanstack/solid-form'
|
|
@@ -7,10 +7,13 @@ interface FieldInfoProps {
|
|
|
7
7
|
field: AnyFieldApi
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
<% if (codeRouter) { %>
|
|
11
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
12
|
+
<% } else { %>
|
|
10
13
|
export const Route = createFileRoute('/demo/form')({
|
|
11
14
|
component: FormExample,
|
|
12
15
|
})
|
|
13
|
-
|
|
16
|
+
<% } %>
|
|
14
17
|
function FieldInfo(props: FieldInfoProps) {
|
|
15
18
|
return (
|
|
16
19
|
<>
|
|
@@ -134,3 +137,12 @@ function FormExample() {
|
|
|
134
137
|
</div>
|
|
135
138
|
)
|
|
136
139
|
}
|
|
140
|
+
|
|
141
|
+
<% if (codeRouter) { %>
|
|
142
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
143
|
+
path: '/demo/form',
|
|
144
|
+
component: FormExample,
|
|
145
|
+
getParentRoute: () => parentRoute,
|
|
146
|
+
})
|
|
147
|
+
<% } %>
|
|
148
|
+
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/solid-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/solid-router'
|
|
2
2
|
import { useStore } from '@tanstack/solid-store'
|
|
3
3
|
|
|
4
4
|
import { store } from '../lib/demo-store'
|
|
5
5
|
|
|
6
|
+
<% if (codeRouter) { %>
|
|
7
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
8
|
+
<% } else { %>
|
|
6
9
|
export const Route = createFileRoute('/demo/store/page1')({
|
|
7
|
-
component:
|
|
10
|
+
component: DemoStorePage1,
|
|
8
11
|
})
|
|
12
|
+
<% } %>
|
|
9
13
|
|
|
10
|
-
function
|
|
14
|
+
function DemoStorePage1() {
|
|
11
15
|
const count = useStore(store, (state) => state.count)
|
|
12
16
|
|
|
13
17
|
return (
|
|
@@ -27,4 +31,11 @@ function App() {
|
|
|
27
31
|
)
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
<% if (codeRouter) { %>
|
|
35
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
36
|
+
path: '/demo/store/page1',
|
|
37
|
+
component: DemoStorePage1,
|
|
38
|
+
getParentRoute: () => parentRoute,
|
|
39
|
+
})
|
|
40
|
+
<% } %>
|
|
41
|
+
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/solid-router'
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/solid-router'
|
|
2
2
|
import { useStore } from '@tanstack/solid-store'
|
|
3
3
|
|
|
4
4
|
import { store } from '../lib/demo-store'
|
|
5
5
|
|
|
6
|
+
<% if (codeRouter) { %>
|
|
7
|
+
import type { RootRoute } from '@tanstack/react-router'
|
|
8
|
+
<% } else { %>
|
|
6
9
|
export const Route = createFileRoute('/demo/store/page2')({
|
|
7
|
-
component:
|
|
10
|
+
component: DemoStorePage2,
|
|
8
11
|
})
|
|
9
|
-
|
|
10
|
-
function
|
|
12
|
+
<% } %>
|
|
13
|
+
function DemoStorePage2() {
|
|
11
14
|
const count = useStore(store, (state) => state.count)
|
|
12
15
|
|
|
13
16
|
return (
|
|
@@ -27,4 +30,10 @@ function App() {
|
|
|
27
30
|
)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
<% if (codeRouter) { %>
|
|
34
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
35
|
+
path: '/demo/store/page2',
|
|
36
|
+
component: DemoStorePage2,
|
|
37
|
+
getParentRoute: () => parentRoute,
|
|
38
|
+
})
|
|
39
|
+
<% } %>
|
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
} from "@tanstack/solid-router";
|
|
8
8
|
// import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
|
9
9
|
import { render } from 'solid-js/web'
|
|
10
|
+
<% for(const route of routes) { %>import <%= route.name %> from "<%= route.path %>";
|
|
11
|
+
<% } %><% if (routes.length > 0) { %>
|
|
12
|
+
import Header from "./components/Header";
|
|
13
|
+
<% } %>
|
|
10
14
|
|
|
11
15
|
import "./styles.css";
|
|
12
16
|
|
|
@@ -15,6 +19,7 @@ import App from "./App.<%= jsx %>";
|
|
|
15
19
|
const rootRoute = createRootRoute({
|
|
16
20
|
component: () => (
|
|
17
21
|
<>
|
|
22
|
+
<% if (routes.length > 0) { %><Header /><% } %>
|
|
18
23
|
<Outlet />
|
|
19
24
|
{/* <TanStackRouterDevtools /> */}
|
|
20
25
|
</>
|
|
@@ -27,7 +32,7 @@ const indexRoute = createRoute({
|
|
|
27
32
|
component: App,
|
|
28
33
|
});
|
|
29
34
|
|
|
30
|
-
const routeTree = rootRoute.addChildren([indexRoute]);
|
|
35
|
+
const routeTree = rootRoute.addChildren([indexRoute<%= routes.map(route => `, ${route.name}(rootRoute)`).join('') %>]);
|
|
31
36
|
|
|
32
37
|
const router = createRouter({
|
|
33
38
|
routeTree,
|
|
File without changes
|
|
File without changes
|