diff --git a/HDesign/src/components/TopNav/TopNav.tsx b/HDesign/src/components/TopNav/TopNav.tsx index 05960af34..5c3d2a2fd 100644 --- a/HDesign/src/components/TopNav/TopNav.tsx +++ b/HDesign/src/components/TopNav/TopNav.tsx @@ -1,5 +1,5 @@ /** @jsxImportSource @emotion/react */ -import {useNavigate} from 'react-router-dom'; +import {useLocation, useNavigate} from 'react-router-dom'; import TextButton from '../TextButton/TextButton'; import {topNavNonStyle, topNavStyle} from './TopNav.style'; import {TopNavProps} from './TopNav.type'; @@ -11,10 +11,13 @@ import {useState} from 'react'; const TopNav = ({navType}: TopNavProps) => { const [nav, setNav] = useState('홈'); const navigate = useNavigate(); + const location = useLocation(); + + const basePath = location.pathname.split('/').slice(0, -1).join('/'); const PATH_TABLE: Record = { - 홈: '.', - 관리: './admin', + 홈: `${basePath}/home`, + 관리: `${basePath}/admin`, }; const handleRoute = (nav: string) => {