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,15 +1,28 @@
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 = () => {
<Navigation/> const location = useLocation();
<Box height="100vh" display="flex" flexDirection="column" sx={{ml: 5, mr: 5}}> useEffect(() => {
<Toolbar/> [...routes, ...footerRoutes].forEach(route => {
<Outlet/> if (route.path === location.pathname) document.title = `LicenseAPI - ${route.name}`;
});
}, [location]);
<Footer/> return (<>
</Box> <Navigation/>
</>
<Box height="100vh" display="flex" flexDirection="column" sx={{ml: 5, mr: 5}}>
<Toolbar/>
<Outlet/>
<Footer/>
</Box>
</>);
}