Skip to content

Commit cbe4001

Browse files
committed
Add link to about page in header
1 parent 1d00c70 commit cbe4001

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

app/about/page.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,7 @@ export default function AboutPage() {
8383
Home page with categories:
8484
</Typography>
8585

86-
<Box
87-
height={560}
88-
width={1}
89-
position="relative"
90-
border={1}
91-
borderRadius={2}
92-
overflow="hidden"
93-
>
86+
<Box height={560} width={1} position="relative" overflow="hidden">
9487
<Image
9588
src="/about/categories.png"
9689
alt="Categories example"
@@ -105,11 +98,9 @@ export default function AboutPage() {
10598
</Typography>
10699

107100
<Box
108-
height={550}
101+
height={560}
109102
width={1}
110103
position="relative"
111-
border={1}
112-
borderRadius={2}
113104
mt={2}
114105
overflow="hidden"
115106
>

components/Header.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ import {
1717
} from "@mui/material";
1818
import { useGetUser } from "@/hooks";
1919
import { useColorMode } from "@/providers";
20+
import { usePathname } from "next/navigation";
21+
import { ABOUT_PAGE_ROUTE } from "@/types";
2022

2123
export const Header = () => {
2224
const { userName, userImage, userId, userEmail } = useGetUser();
2325
const [anchorElUser, setAnchorElUser] = useState<null | HTMLElement>(null);
24-
2526
const { theme, toggleTheme } = useColorMode();
27+
const pathName = usePathname();
28+
const isAboutPage = pathName === ABOUT_PAGE_ROUTE;
2629

2730
const onOpenUserMenu = (event: MouseEvent<HTMLElement>) => {
2831
setAnchorElUser(event.currentTarget);
@@ -100,7 +103,7 @@ export const Header = () => {
100103
<Typography
101104
component={Link}
102105
width={1}
103-
href="/about"
106+
href={ABOUT_PAGE_ROUTE}
104107
color="primary"
105108
>
106109
About
@@ -115,6 +118,19 @@ export const Header = () => {
115118
</Menu>
116119
</Box>
117120
)}
121+
122+
{!userId && !isAboutPage && (
123+
<Box sx={{ flexGrow: 0 }}>
124+
<Typography
125+
component={Link}
126+
width={1}
127+
href={ABOUT_PAGE_ROUTE}
128+
color="primary"
129+
>
130+
About
131+
</Typography>
132+
</Box>
133+
)}
118134
</Toolbar>
119135
</Container>
120136
</AppBar>

types/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export const LIGHT_THEME = "light";
1717
export const DARK_THEME = "dark";
1818
export const LIGHT_TEXT = "light-text";
1919
export const DARK_TEXT = "dark-text";
20+
21+
// Routes
22+
export const ABOUT_PAGE_ROUTE = "/about";

0 commit comments

Comments
 (0)