@@ -44,6 +44,10 @@ export type TargetTemplate = {
4444 }
4545}
4646
47+ function serializeRoutePath ( routePath : string ) {
48+ return JSON . stringify ( routePath )
49+ }
50+
4751export function getTargetTemplate ( config : Config ) : TargetTemplate {
4852 const target = config . target
4953 switch ( target ) {
@@ -79,7 +83,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
7983 tsrImports : ( ) =>
8084 "import { createFileRoute } from '@tanstack/react-router';" ,
8185 tsrExportStart : ( routePath ) =>
82- `export const Route = createFileRoute(' ${ routePath } ' )(` ,
86+ `export const Route = createFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
8387 tsrExportEnd : ( ) => ');' ,
8488 } ,
8589 } ,
@@ -95,7 +99,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
9599 tsrImports : ( ) =>
96100 "import { createLazyFileRoute } from '@tanstack/react-router';" ,
97101 tsrExportStart : ( routePath ) =>
98- `export const Route = createLazyFileRoute(' ${ routePath } ' )(` ,
102+ `export const Route = createLazyFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
99103 tsrExportEnd : ( ) => ');' ,
100104 } ,
101105 } ,
@@ -132,7 +136,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
132136 tsrImports : ( ) =>
133137 "import { createFileRoute } from '@tanstack/solid-router';" ,
134138 tsrExportStart : ( routePath ) =>
135- `export const Route = createFileRoute(' ${ routePath } ' )(` ,
139+ `export const Route = createFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
136140 tsrExportEnd : ( ) => ');' ,
137141 } ,
138142 } ,
@@ -149,7 +153,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
149153 "import { createLazyFileRoute } from '@tanstack/solid-router';" ,
150154
151155 tsrExportStart : ( routePath ) =>
152- `export const Route = createLazyFileRoute(' ${ routePath } ' )(` ,
156+ `export const Route = createLazyFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
153157
154158 tsrExportEnd : ( ) => ');' ,
155159 } ,
@@ -188,7 +192,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
188192 tsrImports : ( ) =>
189193 "import { createFileRoute } from '@tanstack/vue-router';" ,
190194 tsrExportStart : ( routePath ) =>
191- `export const Route = createFileRoute(' ${ routePath } ' )(` ,
195+ `export const Route = createFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
192196 tsrExportEnd : ( ) => ');' ,
193197 } ,
194198 } ,
@@ -206,7 +210,7 @@ export function getTargetTemplate(config: Config): TargetTemplate {
206210 "import { createLazyFileRoute } from '@tanstack/vue-router';" ,
207211
208212 tsrExportStart : ( routePath ) =>
209- `export const Route = createLazyFileRoute(' ${ routePath } ' )(` ,
213+ `export const Route = createLazyFileRoute(${ serializeRoutePath ( routePath ) } )(` ,
210214
211215 tsrExportEnd : ( ) => ');' ,
212216 } ,
0 commit comments