-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
61 lines (57 loc) · 1.22 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { lazy, Suspense } from 'react'
import {
Route,
BrowserRouter as Router,
Routes,
useParams,
} from 'react-router-dom'
import './global.scss'
import 'github-markdown-css'
const Readme = () => {
const { name } = useParams<{ name: string }>()
const Readme = lazy(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
name ? import(`../packages/${name}/README.md`) : import('../README.md'),
)
return (
<Suspense>
<Readme />
</Suspense>
)
}
const Changelog = () => {
const { name } = useParams<{ name: string }>()
const Changelog = lazy(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
name
? import(`../packages/${name}/CHANGELOG.md`)
: import('../CHANGELOG.md'),
)
return (
<Suspense>
<Changelog />
</Suspense>
)
}
export const App = () => (
<Router>
<Routes>
<Route
path="/CHANGELOG.md"
element={<Changelog />}
/>
<Route
path="/packages/:name"
element={<Readme />}
/>
<Route
path="/packages/:name/CHANGELOG.md"
element={<Changelog />}
/>
<Route
path="/"
element={<Readme />}
/>
</Routes>
</Router>
)