client: distinguish current page in header
This commit is contained in:
parent
bf878473af
commit
65b0c8f7f3
2 changed files with 3 additions and 3 deletions
|
@ -18,7 +18,7 @@ type Tab = {
|
||||||
|
|
||||||
const Header = ({ changeTheme, theme }: DriftProps) => {
|
const Header = ({ changeTheme, theme }: DriftProps) => {
|
||||||
const router = useRouter();
|
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 [expanded, setExpanded] = useState<boolean>(false)
|
||||||
const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true })
|
const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true })
|
||||||
const isMobile = useMediaQuery('xs', { match: 'down' })
|
const isMobile = useMediaQuery('xs', { match: 'down' })
|
||||||
|
@ -91,7 +91,7 @@ const Header = ({ changeTheme, theme }: DriftProps) => {
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
changeTheme();
|
changeTheme();
|
||||||
setSelectedTab(undefined);
|
setSelectedTab('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: theme === 'light' ? <Moon /> : <Sun />,
|
icon: theme === 'light' ? <Moon /> : <Sun />,
|
||||||
|
|
|
@ -38,7 +38,7 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
||||||
}
|
}
|
||||||
} else if (pathname === '/new') {
|
} else if (pathname === '/new') {
|
||||||
if (!signedIn) {
|
if (!signedIn) {
|
||||||
return NextResponse.redirect(getURL(''))
|
return NextResponse.redirect(getURL('/signin'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue