Skip to content

Commit

Permalink
Merge pull request #41 from Code-Odyssey-Editor/nikhil
Browse files Browse the repository at this point in the history
Patch - 0.0.6 Fix Refresh Page and Other Issues
  • Loading branch information
Cheemagagan authored Nov 7, 2023
2 parents e0fa49e + 0722f84 commit 5b9a55c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
22 changes: 22 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<script type="text/javascript">
var pathSegmentsToKeep = 1;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);

</script>
</head>
<body>
</body>
</html>
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/logo/logo.png" />
<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
(function(l) {
if (l.search[1] === '/' ) {
var decoded = l.search.slice(1).split('&').map(function(s) {
return s.replace(/~and~/g, '&')
}).join('?');
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
}(window.location))
</script>
<!-- End Single Page Apps for GitHub Pages -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Code Odyssey Editor</title>
</head>
Expand Down
29 changes: 22 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,44 @@ import aboutpage from "./pages/aboutpage";
import editorpage from "./pages/editor/editorpage";
import SignIn from "./pages/auth/signinpage";
import Signup from "./pages/auth/signuppage";
import { Spinner } from "@nextui-org/react";

// Router
const router = createBrowserRouter([{ path: "*", Component: Root }]);
const router = createBrowserRouter([{ path: "/website/*", Component: Root , ErrorBoundary: Root}]);

// 1️⃣ Changed from App to Root
function Root() {
// 2️⃣ `BrowserRouter` component removed, but the <Routes>/<Route>
// component below are unchanged
return (
<Routes>
<Route path="/website" Component={homepage} />
<Route path="/website/about" Component={aboutpage} />
<Route path="/website/editor" Component={editorpage} />
<Route path="/website/sign-in" Component={SignIn} />
<Route path="/website/sign-up" Component={Signup} />
<Route path="/" Component={homepage} />
<Route path="/about" Component={aboutpage} />
<Route path="/editor" Component={editorpage} />
<Route path="/sign-in" Component={SignIn} />
<Route path="/sign-up" Component={Signup} />
</Routes>
);
}

// Spinner Element
function SpinnerElement() {
return ( <div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100vh",
}}
>
<Spinner label="Loading..." color="success" labelColor="success" />
</div>)
}

export default function App() {
return (
<NextThemesProvider attribute="class" defaultTheme="dark">
<RouterProvider router={router} />
<RouterProvider router={router} fallbackElement={<SpinnerElement />} />
</NextThemesProvider>
);
}

0 comments on commit 5b9a55c

Please sign in to comment.