From 4440cf7fa2a112b42ac966bd125ba289df439baf Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Tue, 22 Oct 2024 20:50:36 +0300 Subject: [PATCH] navigation --- bro.config.js | 3 ++- src/__data__/urls.ts | 20 ++++++++++++++++++++ src/app.tsx | 2 +- src/dashboard.tsx | 11 +++++++---- src/pages/about.ts | 0 src/pages/about.tsx | 13 +++++++++++++ src/pages/profile.ts | 0 src/pages/profile.tsx | 13 +++++++++++++ 8 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 src/__data__/urls.ts delete mode 100644 src/pages/about.ts create mode 100644 src/pages/about.tsx delete mode 100644 src/pages/profile.ts create mode 100644 src/pages/profile.tsx diff --git a/bro.config.js b/bro.config.js index fd6f0b9..5b707e6 100644 --- a/bro.config.js +++ b/bro.config.js @@ -10,7 +10,8 @@ module.exports = { /* use https://admin.bro-js.ru/ to create config, navigations and features */ navigations: { "nav1.main": "/nav1", - "nav1.": "" + "link.nav1.about": "/", + "link.nav1.profile": "/my-best-profile-page-ever" }, features: { "nav1": { diff --git a/src/__data__/urls.ts b/src/__data__/urls.ts new file mode 100644 index 0000000..351601d --- /dev/null +++ b/src/__data__/urls.ts @@ -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; + }, + }, +}; diff --git a/src/app.tsx b/src/app.tsx index 2a3d784..98b995d 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,7 +5,7 @@ import { Dashboard } from './dashboard'; const App = () => { return ( - + ); diff --git a/src/dashboard.tsx b/src/dashboard.tsx index 61048f2..d76ed27 100644 --- a/src/dashboard.tsx +++ b/src/dashboard.tsx @@ -1,13 +1,16 @@ import React from "react"; 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 = () => { return ( - Dashboard} /> - - about} /> - profile} /> + } /> + {URLs.profile.isOn && } />} Not found} /> diff --git a/src/pages/about.ts b/src/pages/about.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/about.tsx b/src/pages/about.tsx new file mode 100644 index 0000000..85242ed --- /dev/null +++ b/src/pages/about.tsx @@ -0,0 +1,13 @@ +import React from "react"; +import { Link } from "react-router-dom"; + +import { URLs } from "../__data__/urls"; + +export const AboutPage = () => { + return ( +
+

about page

+ {URLs.profile.isOn && go to profile page} +
+ ); +}; diff --git a/src/pages/profile.ts b/src/pages/profile.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx new file mode 100644 index 0000000..77a4b4a --- /dev/null +++ b/src/pages/profile.tsx @@ -0,0 +1,13 @@ +import React from "react"; +import { Link } from "react-router-dom"; + +import { URLs } from "../__data__/urls"; + +export const ProfilePage = () => { + return ( +
+

profile page

+ go to about page +
+ ); +};