Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/common/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@ const Layout = () => {
const location = useLocation();

useEffect(() => {
sendPageView(location.pathname + location.search + location.hash);
// 라우트별 페이지 타이틀 설정
const path = location.pathname;
const titleRules: Array<[RegExp, string]> = [
[/^\/$/, 'THIP - 로그인'],
[/^\/feed(\/|$)/, 'THIP - 피드'],
[/^\/notice(\/|$)/, 'THIP - 알림'],
[/^\/group(\/|$)/, 'THIP - 모임'],
[/^\/rooms\/[^/]+\/memory(\/|$)/, 'THIP - 기록장'],
[/^\/mypage(\/|$)/, 'THIP - 마이페이지'],
[/^\/search(\/|$)/, 'THIP - 책 검색'],
];

const matched = titleRules.find(([regex]) => regex.test(path));
if (matched) {
document.title = matched[1];
} else {
document.title = 'THIP';
}

sendPageView(path + location.search + location.hash);
}, [location.pathname, location.search, location.hash]);

return (
Expand Down