client: distinguish current page in header

This commit is contained in:
Max Leiter 2022-03-21 02:15:36 -07:00
parent bf878473af
commit 65b0c8f7f3
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A3512F2F2F17EBDA
2 changed files with 3 additions and 3 deletions

View file

@ -18,7 +18,7 @@ type Tab = {
const Header = ({ changeTheme, theme }: DriftProps) => {
const router = useRouter();
const [selectedTab, setSelectedTab] = useState<string>();
const [selectedTab, setSelectedTab] = useState<string>(router.pathname === '/' ? 'home' : router.pathname.split('/')[1]);
const [expanded, setExpanded] = useState<boolean>(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' ? <Moon /> : <Sun />,

View file

@ -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'))
}
}