navigation
This commit is contained in:
parent
580ce0f81d
commit
4440cf7fa2
@ -10,7 +10,8 @@ module.exports = {
|
|||||||
/* use https://admin.bro-js.ru/ to create config, navigations and features */
|
/* use https://admin.bro-js.ru/ to create config, navigations and features */
|
||||||
navigations: {
|
navigations: {
|
||||||
"nav1.main": "/nav1",
|
"nav1.main": "/nav1",
|
||||||
"nav1.": ""
|
"link.nav1.about": "/",
|
||||||
|
"link.nav1.profile": "/my-best-profile-page-ever"
|
||||||
},
|
},
|
||||||
features: {
|
features: {
|
||||||
"nav1": {
|
"nav1": {
|
||||||
|
20
src/__data__/urls.ts
Normal file
20
src/__data__/urls.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { getNavigationsValue } from "@brojs/cli";
|
||||||
|
import { generatePath } from "react-router-dom";
|
||||||
|
|
||||||
|
const baseUrl = getNavigationsValue("nav1.main");
|
||||||
|
|
||||||
|
export const URLs = {
|
||||||
|
profile: {
|
||||||
|
isOn: Boolean(getNavigationsValue("link.nav1.profile")),
|
||||||
|
url: `${baseUrl}${getNavigationsValue("link.nav1.profile")}`,
|
||||||
|
getUrl() {
|
||||||
|
return this.url;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
about: {
|
||||||
|
url: `${baseUrl}${getNavigationsValue("link.nav1.about")}`,
|
||||||
|
getUrl() {
|
||||||
|
return this.url;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
@ -5,7 +5,7 @@ import { Dashboard } from './dashboard';
|
|||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter basename='/nav1'>
|
<BrowserRouter>
|
||||||
<Dashboard />
|
<Dashboard />
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Routes, Route } from "react-router-dom";
|
import { Routes, Route } from "react-router-dom";
|
||||||
|
|
||||||
|
import { URLs } from "./__data__/urls";
|
||||||
|
import { ProfilePage } from './pages/profile'
|
||||||
|
import { AboutPage } from "./pages/about";
|
||||||
|
|
||||||
|
|
||||||
export const Dashboard = () => {
|
export const Dashboard = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<div>Dashboard</div>} />
|
<Route path={URLs.about.url} element={<AboutPage />} />
|
||||||
|
{URLs.profile.isOn && <Route path={URLs.profile.url} element={<ProfilePage />} />}
|
||||||
<Route path="/about" element={<div>about</div>} />
|
|
||||||
<Route path="/profile" element={<div>profile</div>} />
|
|
||||||
|
|
||||||
<Route path="*" element={<div>Not found</div>} />
|
<Route path="*" element={<div>Not found</div>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
13
src/pages/about.tsx
Normal file
13
src/pages/about.tsx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
|
import { URLs } from "../__data__/urls";
|
||||||
|
|
||||||
|
export const AboutPage = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>about page</h1>
|
||||||
|
{URLs.profile.isOn && <Link to={URLs.profile.getUrl()}>go to profile page</Link>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
13
src/pages/profile.tsx
Normal file
13
src/pages/profile.tsx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
|
import { URLs } from "../__data__/urls";
|
||||||
|
|
||||||
|
export const ProfilePage = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>profile page</h1>
|
||||||
|
<Link to={URLs.about.getUrl()}>go to about page</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user