From 65b0c8f7f39def271f0112cf31439074bc216bb2 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Mon, 21 Mar 2022 02:15:36 -0700 Subject: [PATCH] client: distinguish current page in header --- client/components/header/index.tsx | 4 ++-- client/pages/_middleware.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/components/header/index.tsx b/client/components/header/index.tsx index d8feabce..d5905f22 100644 --- a/client/components/header/index.tsx +++ b/client/components/header/index.tsx @@ -18,7 +18,7 @@ type Tab = { const Header = ({ changeTheme, theme }: DriftProps) => { const router = useRouter(); - const [selectedTab, setSelectedTab] = useState(); + const [selectedTab, setSelectedTab] = useState(router.pathname === '/' ? 'home' : router.pathname.split('/')[1]); const [expanded, setExpanded] = useState(false) const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true }) const isMobile = useMediaQuery('xs', { match: 'down' }) @@ -91,7 +91,7 @@ const Header = ({ changeTheme, theme }: DriftProps) => { onClick: function () { if (typeof window !== 'undefined') { changeTheme(); - setSelectedTab(undefined); + setSelectedTab(''); } }, icon: theme === 'light' ? : , diff --git a/client/pages/_middleware.tsx b/client/pages/_middleware.tsx index a7909c91..e31452e4 100644 --- a/client/pages/_middleware.tsx +++ b/client/pages/_middleware.tsx @@ -38,7 +38,7 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) { } } else if (pathname === '/new') { if (!signedIn) { - return NextResponse.redirect(getURL('')) + return NextResponse.redirect(getURL('/signin')) } }