1
1
import { Fragment } from 'react' ;
2
- import { Route , Routes } from 'react-router-dom' ;
3
- import { ConfigProvider } from 'antd' ;
2
+ import { Route , Routes , useNavigate } from 'react-router-dom' ;
3
+ import { ConfigProvider , Layout , Menu } from 'antd' ;
4
4
import { Footer } from './components/elements' ;
5
+ import Sider from 'antd/es/layout/Sider' ;
6
+ import { HomeOutlined , InfoCircleOutlined , ProjectOutlined } from '@ant-design/icons' ;
7
+
5
8
6
9
const PRESERVED : {
7
10
[ key : string ] : { default : React . ComponentType } ;
@@ -31,9 +34,11 @@ const routes = Object.keys(ROUTES).map((route) => {
31
34
return { path, component : ROUTES [ route ] . default } ;
32
35
} ) ;
33
36
37
+
34
38
function App ( ) {
35
39
const App = preserved ?. [ '_app' ] || Fragment ;
36
40
const NotFound = preserved ?. [ '_404' ] || Fragment ;
41
+ const navigate = useNavigate ( ) ;
37
42
38
43
return (
39
44
< ConfigProvider
@@ -43,15 +48,33 @@ function App() {
43
48
}
44
49
} }
45
50
>
46
- < App >
47
- < Routes >
48
- { routes . map ( ( { path, component : Component = Fragment } ) => (
49
- < Route key = { path } path = { path } element = { < Component /> } />
50
- ) ) }
51
- < Route path = "*" element = { < NotFound /> } />
52
- </ Routes >
53
- < Footer />
54
- </ App >
51
+ < Layout style = { { minHeight : '100vh' } } >
52
+ < Sider collapsible >
53
+ < Menu theme = "dark" defaultSelectedKeys = { [ '1' ] } mode = "inline" className = 'flex flex-col justify-center items-center py-8 px-4 fixed' >
54
+ < Menu . Item key = "1" icon = { < HomeOutlined /> } onClick = { ( ) => navigate ( '/' ) } >
55
+ Home
56
+ </ Menu . Item >
57
+ < Menu . Item key = "2" icon = { < InfoCircleOutlined /> } onClick = { ( ) => navigate ( '/about' ) } >
58
+ About
59
+ </ Menu . Item >
60
+ < Menu . Item key = "3" icon = { < ProjectOutlined /> } onClick = { ( ) => navigate ( '/works' ) } >
61
+ Work
62
+ </ Menu . Item >
63
+ </ Menu >
64
+ </ Sider >
65
+
66
+ < main className = "flex flex-col" >
67
+ < App >
68
+ < Routes >
69
+ { routes . map ( ( { path, component : Component = Fragment } ) => (
70
+ < Route key = { path } path = { path } element = { < Component /> } />
71
+ ) ) }
72
+ < Route path = "*" element = { < NotFound /> } />
73
+ </ Routes >
74
+ </ App >
75
+ < Footer />
76
+ </ main >
77
+ </ Layout >
55
78
</ ConfigProvider >
56
79
) ;
57
80
}
0 commit comments