1- import { createElement } from 'react'
21import pages from '@orga-build/pages'
32import layouts from '@orga-build/layouts'
43import * as components from '@orga-build/components'
5- import { Link , useRoutes } from 'react-router '
4+ import { Route , Switch , Link } from 'wouter '
65
76export function App ( ) {
87 const _pages = Object . entries ( pages ) . map ( ( [ path , page ] ) => {
@@ -16,19 +15,13 @@ export function App() {
1615 const layoutIds = Object . keys ( layouts )
1716 . filter ( ( key ) => path . startsWith ( key ) )
1817 . sort ( ( a , b ) => - a . localeCompare ( b ) )
19- let element = createElement ( page . default , {
20- components : { ...components , Link }
21- } )
18+ let element = < page . default components = { { ...components , Link, a : Link } } />
2219 for ( const layoutId of layoutIds ) {
23- element = createElement (
24- layouts [ layoutId ] ,
25- {
26- title : page . title ,
27- slug : path ,
28- ...page ,
29- pages : _pages
30- } ,
31- element
20+ const Layout = layouts [ layoutId ]
21+ element = (
22+ < Layout title = { page . title } slug = { path } pages = { _pages } { ...page } >
23+ { element }
24+ </ Layout >
3225 )
3326 }
3427 return {
@@ -37,5 +30,15 @@ export function App() {
3730 }
3831 } )
3932
40- return useRoutes ( pageRoutes )
33+ return (
34+ < Switch >
35+ { pageRoutes . map ( ( route ) => {
36+ return (
37+ < Route key = { `r-${ route . path } ` } path = { route . path } >
38+ { route . element }
39+ </ Route >
40+ )
41+ } ) }
42+ </ Switch >
43+ )
4144}
0 commit comments