Skip to content

Commit

Permalink
Added home redirect for '/Club-Website'
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganlenz001 committed Oct 4, 2023
1 parent d058839 commit 0baf9d4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import {SetStateAction, useState} from "react";
import {BrowserRouter as Router, Route, Routes} from "react-router-dom";
import {BrowserRouter as Router, Route, Routes, useNavigate} from "react-router-dom";
import Home from "./pages/home";
import Project from "./pages/project"
import About from "./pages/about";
Expand All @@ -20,7 +21,7 @@ function App() {
// project_path = "/:" + Projects_Content[i][1][1].replace(/\s/g, "-"); // Replace spaces with dashes for url
project_routes.push (
// Project_Content[i][1][1] gets first element after descriptor from project page (should probably be a title)
<Route path={`/:${Projects_Content[i][1][1].replace(/\s/g, "-")}`} element={<Project></Project>} key={i}></Route>
<Route key={i} path={`/:${Projects_Content[i][1][1].replace(/\s/g, "-")}`} element={<Project></Project>}></Route>
)
}

Expand All @@ -29,6 +30,8 @@ function App() {
<Router>
<Navigation_Bar nav_bar_title={nav_bar_title} onNavLinkClick={update_title}></Navigation_Bar>
<Routes>
<Route path="/Club-Website" element={<RedirectToHome></RedirectToHome>}></Route>

<Route path="/" element={<Home></Home>}></Route>
{project_routes}
<Route path="/about" element={<About></About>}></Route>
Expand All @@ -39,4 +42,13 @@ function App() {
);
}

function RedirectToHome() {
const navigate = useNavigate();
React.useEffect(() => {
navigate("/");
}, []);

return null;
}

export default App;

0 comments on commit 0baf9d4

Please sign in to comment.