The Root.jsx now updates the page title

This commit is contained in:
Mathias Wagner 2023-07-09 18:22:22 +02:00
parent 7e682671f7
commit dfe71f37d7
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,9 +1,21 @@
import Navigation from "@components/Navigation"; import Navigation from "@components/Navigation";
import {Outlet} from "react-router-dom"; import {Outlet, useLocation} from "react-router-dom";
import {Box, Toolbar} from "@mui/material"; import {Box, Toolbar} from "@mui/material";
import Footer from "@components/Footer"; import Footer from "@components/Footer";
import {useEffect} from "react";
import routes from "@/common/routes";
import footerRoutes from "@/common/routes/footer.jsx";
export const Root = () => <> export const Root = () => {
const location = useLocation();
useEffect(() => {
[...routes, ...footerRoutes].forEach(route => {
if (route.path === location.pathname) document.title = `LicenseAPI - ${route.name}`;
});
}, [location]);
return (<>
<Navigation/> <Navigation/>
<Box height="100vh" display="flex" flexDirection="column" sx={{ml: 5, mr: 5}}> <Box height="100vh" display="flex" flexDirection="column" sx={{ml: 5, mr: 5}}>
@ -12,4 +24,5 @@ export const Root = () => <>
<Footer/> <Footer/>
</Box> </Box>
</> </>);
}