diff --git a/src/components/Head/Head.tsx b/src/components/Head/Head.tsx new file mode 100644 index 00000000..885d9eb4 --- /dev/null +++ b/src/components/Head/Head.tsx @@ -0,0 +1,11 @@ +import {Helmet} from 'react-helmet-async'; + +function Head({title}: {title: string}) { + return ( + + TRIPVOTE | {title} + + ); +} + +export default Head; diff --git a/src/routes/MainRouter/MainRouter.tsx b/src/routes/MainRouter/MainRouter.tsx index 434d5ddb..c378cc2c 100644 --- a/src/routes/MainRouter/MainRouter.tsx +++ b/src/routes/MainRouter/MainRouter.tsx @@ -1,6 +1,6 @@ -import {useEffect, useState} from 'react'; -import {Helmet} from 'react-helmet-async'; -import {Route, Routes, useLocation} from 'react-router-dom'; +import {Route, Routes} from 'react-router-dom'; + +import Head from '@/components/Head/Head'; import AddPlaceFromVote from '@/pages/AddPlaceFromVote/AddPlaceFromVote'; import FindPassword from '@/pages/Auth/FindPassword/FindPassword'; @@ -28,51 +28,247 @@ import Vote from '@/pages/Vote/Vote'; import VoteMemo from '@/pages/Vote/VoteMemo/VoteMemo'; import Wishes from '@/pages/Wishes/Wishes'; import Dashboard from '@/routes/Dashboard/Dashboard'; -import {getTitle} from '@/utils/getTitle'; function MainRouter() { - const [title, setTitle] = useState(''); - const location = useLocation(); - useEffect(() => { - setTitle(getTitle(location.pathname)); - }, [location]); - return ( - <> - - TRIPVOTE | {title} - - - }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - + + }> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + + + + + } + /> + ); } diff --git a/src/utils/getTitle.ts b/src/utils/getTitle.ts deleted file mode 100644 index b3324315..00000000 --- a/src/utils/getTitle.ts +++ /dev/null @@ -1,48 +0,0 @@ -export const getTitle = (pathname: string) => { - if (pathname.startsWith('/trip/') && /\d+$/.test(pathname)) { - return '여행스페이스'; - } - if (pathname.startsWith('/votes/') && pathname.endsWith('/map')) { - return '지도'; - } - if (pathname.startsWith('/votes/') && pathname.endsWith('/votememo')) { - return '메모'; - } - if (pathname.startsWith('/votes/') && /\d+$/.test(pathname)) { - return '투표'; - } - if (pathname.startsWith('/detail/')) { - return '상세'; - } - if (pathname.startsWith('/trip/') && pathname.includes('/selectDate')) { - return '날짜선택'; - } - if (pathname.startsWith('/trip/') && pathname.includes('/selectRegion')) { - return '지역선택'; - } - if (pathname.startsWith('/trip/') && pathname.includes('/map')) { - return '지도'; - } - if (pathname.startsWith('/trip/') && pathname.includes('/add/vote')) { - return '일정추가'; - } - const pathMap: {[key: string]: string} = { - '/': '홈', - '/heart': '찜', - '/user': '마이페이지', - '/user/privacy': '계정관리', - '/user/profile/edit': '프로필 편집', - '/user/myspace': '내 여행스페이스', - '/user/myreview': '내 리뷰', - '/home/search': '검색', - '/auth/login': '로그인', - '/auth/signup': '회원가입', - '/auth/signup/agreePrivacy': '개인정보이용 약관', - '/auth/signup/agreeService': '서비스이용 약관', - '/auth/password/find': '비밀번호 찾기', - '/auth/password/modify': '비밀번호 수정', - '/auth/withdrawal': '다음에 또 만나요', - }; - - return pathMap[pathname] || '알 수 없는 경로'; -};