Skip to content

Commit e6c2cca

Browse files
committed
Fix: Menu item & document titles
1 parent e0dd510 commit e6c2cca

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

src/components/AppBar/index.tsx

+16-19
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,34 @@ export default function AppBar() {
6868
</Typography>
6969
</Link>
7070
</MenuItem>
71-
<MenuItem>
72-
<IconButton
73-
sx={{ gap: 1 }}
74-
onClick={() => {
75-
dispatch(switchTheme());
76-
}}
77-
color="inherit"
78-
>
79-
{theme.isDark ? <Brightness7Icon /> : <Brightness4Icon />}
80-
<Typography>{theme.isDark ? "Dark" : "Light"}</Typography>
81-
</IconButton>
71+
<MenuItem
72+
onClick={() => {
73+
dispatch(switchTheme());
74+
}}
75+
sx={{ gap: 0.5 }}
76+
>
77+
{theme.isDark ? <Brightness7Icon /> : <Brightness4Icon />}
78+
<Typography>{theme.isDark ? "Dark" : "Light"}</Typography>
8279
</MenuItem>
8380
<MenuItem>
84-
<IconButton
85-
sx={{ gap: 1 }}
86-
href="https://github.com/LNReader/lnreader"
81+
<Link
82+
to="https://github.com/LNReader/lnreader"
8783
target="_blank"
84+
style={{ gap: 4, display: "flex" }}
8885
>
8986
<GitHubIcon />
9087
<Typography>Github</Typography>
91-
</IconButton>
88+
</Link>
9289
</MenuItem>
9390
<MenuItem>
94-
<IconButton
95-
sx={{ gap: 1 }}
96-
href="https://discord.com/invite/QdcWN4MD63"
91+
<Link
92+
to="https://discord.com/invite/QdcWN4MD63"
9793
target="_blank"
94+
style={{ gap: 4, display: "flex" }}
9895
>
9996
<DiscordIcon />
10097
<Typography>Discord</Typography>
101-
</IconButton>
98+
</Link>
10299
</MenuItem>
103100
</Menu>
104101
);

src/components/Layout/index.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ import AppBar from "@components/AppBar";
22
import SideBar from "@components/SideBar";
33
import { useTheme } from "@hooks/useTheme";
44
import { Box } from "@mui/material";
5-
import { ReactNode } from "react";
5+
import { ReactNode, useEffect } from "react";
66
import { useLocation } from "react-router-dom";
7+
import routes from "../../../routes.json";
78

89
export default function Layout({ children }: { children: ReactNode }) {
910
const location = useLocation();
1011
const theme = useTheme();
12+
useEffect(() => {
13+
const route = routes.find(
14+
(r) => r.path === location.pathname.replace(/^\//, "")
15+
);
16+
if (route) {
17+
document.title = route.title;
18+
} else {
19+
document.title = "Home | LNReader";
20+
}
21+
}, [location.pathname]);
1122
return (
1223
<Box>
1324
<AppBar />

0 commit comments

Comments
 (0)