@@ -15,98 +15,104 @@ class GlimmerRouter extends Router {
15
15
@tracked activeRoute ;
16
16
}
17
17
18
- // @ts -expect-error
19
- export const router = new GlimmerRouter ( {
20
- main : '' ,
21
- tests : '/tests' ,
22
- benchmark : '/benchmark' ,
23
- pageOne : '/pageOne' ,
24
- pageTwo : '/pageTwo' ,
25
- isPolarisReady : '/is-polaris-ready' ,
26
- todomvc : '/todomvc' ,
27
- 'todomvc.all' : '/todomvc/all' ,
28
- 'todomvc.active' : '/todomvc/active' ,
29
- 'todomvc.completed' : '/todomvc/completed' ,
30
- } ) as RouterType ;
18
+ export function createRouter ( ) {
19
+ // @ts -expect-error
20
+ const router = new GlimmerRouter ( {
21
+ main : '' ,
22
+ tests : '/tests' ,
23
+ benchmark : '/benchmark' ,
24
+ pageOne : '/pageOne' ,
25
+ pageTwo : '/pageTwo' ,
26
+ isPolarisReady : '/is-polaris-ready' ,
27
+ todomvc : '/todomvc' ,
28
+ 'todomvc.all' : '/todomvc/all' ,
29
+ 'todomvc.active' : '/todomvc/active' ,
30
+ 'todomvc.completed' : '/todomvc/completed' ,
31
+ } ) as RouterType ;
32
+
33
+ router . addResolver ( 'isPolarisReady' , async ( ) => {
34
+ // preload css <link rel="preload" href="style.css" as="style" />
35
+ if ( ! import . meta. env . SSR ) {
36
+ const link = document . createElement ( 'link' ) ;
37
+ link . rel = 'preload' ;
38
+ link . href = '/is-polaris-ready.css' ;
39
+ link . as = 'style' ;
40
+ document . head . appendChild ( link ) ;
41
+ }
42
+ const { IsPolarisReady } = await import (
43
+ // @ts -ignore import
44
+ '@/components/pages/IsPolarisReady.gts'
45
+ ) ;
46
+ return {
47
+ component : IsPolarisReady ,
48
+ } ;
49
+ } ) ;
31
50
32
- router . addResolver ( 'isPolarisReady' , async ( ) => {
33
- // preload css <link rel="preload" href="style.css" as="style" />
34
- if ( ! import . meta. env . SSR ) {
35
- const link = document . createElement ( 'link' ) ;
36
- link . rel = 'preload' ;
37
- link . href = '/is-polaris-ready.css' ;
38
- link . as = 'style' ;
39
- document . head . appendChild ( link ) ;
40
- }
41
- const { IsPolarisReady } = await import (
42
- // @ts -ignore import
43
- '@/components/pages/IsPolarisReady.gts'
44
- ) ;
45
- return {
46
- component : IsPolarisReady ,
47
- } ;
48
- } ) ;
51
+ router . addResolver ( 'todomvc' , async ( ) => {
52
+ // preload css <link rel="preload" href="style.css" as="style" />
53
+ console . log ( 'todomvc' ) ;
54
+ if ( ! import . meta. env . SSR ) {
55
+ const link = document . createElement ( 'link' ) ;
56
+ link . rel = 'preload' ;
57
+ link . href = '/todomvc.css' ;
58
+ link . as = 'style' ;
59
+ document . head . appendChild ( link ) ;
60
+ }
61
+ const { ToDoMVC } = await import (
62
+ // @ts -ignore import
63
+ '@/components/pages/ToDoMVC.gts'
64
+ ) ;
65
+ const model = {
66
+ component : ToDoMVC ,
67
+ } ;
68
+ router . _resolvedData [ 'todomvc' ] = {
69
+ model,
70
+ params : { } ,
71
+ } ;
72
+ return model ;
73
+ } ) ;
49
74
50
- router . addResolver ( 'todomvc' , async ( ) => {
51
- // preload css <link rel="preload" href="style.css" as="style" />
52
- console . log ( 'todomvc' ) ;
53
- if ( ! import . meta. env . SSR ) {
54
- const link = document . createElement ( 'link' ) ;
55
- link . rel = 'preload' ;
56
- link . href = '/todomvc.css' ;
57
- link . as = 'style' ;
58
- document . head . appendChild ( link ) ;
59
- }
60
- const { ToDoMVC } = await import (
61
- // @ts -ignore import
62
- '@/components/pages/ToDoMVC.gts'
63
- ) ;
64
- const model = {
65
- component : ToDoMVC ,
66
- } ;
67
- router . _resolvedData [ 'todomvc' ] = {
68
- model,
69
- params : { } ,
70
- } ;
71
- return model ;
72
- } ) ;
75
+ router . addResolver ( 'todomvc.all' , async ( ) => {
76
+ console . log ( 'todomvc.all' ) ;
73
77
74
- router . addResolver ( 'todomvc.all' , async ( ) => {
75
- console . log ( 'todomvc.all' ) ;
78
+ const page = await import (
79
+ // @ts -ignore import
80
+ '@/components/pages/todomvc/page.gts'
81
+ ) ;
82
+ return {
83
+ component : page . default ,
84
+ get model ( ) {
85
+ return repo . all ;
86
+ } ,
87
+ } ;
88
+ } ) ;
89
+ router . addResolver ( 'todomvc.active' , async ( ) => {
90
+ const page = await import (
91
+ // @ts -ignore import
92
+ '@/components/pages/todomvc/page.gts'
93
+ ) ;
94
+ return {
95
+ component : page . default ,
96
+ get model ( ) {
97
+ return repo . active ;
98
+ } ,
99
+ } ;
100
+ } ) ;
76
101
77
- const page = await import (
78
- // @ts -ignore import
79
- '@/components/pages/todomvc/page.gts'
80
- ) ;
81
- return {
82
- component : page . default ,
83
- get model ( ) {
84
- return repo . all ;
85
- } ,
86
- } ;
87
- } ) ;
88
- router . addResolver ( 'todomvc.active' , async ( ) => {
89
- const page = await import (
90
- // @ts -ignore import
91
- '@/components/pages/todomvc/page.gts'
92
- ) ;
93
- return {
94
- component : page . default ,
95
- get model ( ) {
96
- return repo . active ;
97
- } ,
98
- } ;
99
- } ) ;
102
+ router . addResolver ( 'todomvc.completed' , async ( ) => {
103
+ const page = await import (
104
+ // @ts -ignore import
105
+ '@/components/pages/todomvc/page.gts'
106
+ ) ;
107
+ return {
108
+ component : page . default ,
109
+ get model ( ) {
110
+ return repo . completed ;
111
+ } ,
112
+ } ;
113
+ } ) ;
114
+
115
+ return router ;
116
+ }
100
117
101
- router . addResolver ( 'todomvc.completed' , async ( ) => {
102
- const page = await import (
103
- // @ts -ignore import
104
- '@/components/pages/todomvc/page.gts'
105
- ) ;
106
- return {
107
- component : page . default ,
108
- get model ( ) {
109
- return repo . completed ;
110
- } ,
111
- } ;
112
- } ) ;
118
+ export const router = createRouter ( ) ;
0 commit comments