1
0

Reworking routes

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-01-02 23:04:13 -08:00
parent 623cd50862
commit e330795a7b
3 changed files with 56 additions and 47 deletions

View File

@ -1,35 +1,43 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
name="description"
content="Web site created using create-react-app"
/>
<base href="%PUBLIC_URL%/">
<link rel="icon" href="./assets/favicon-32.png" sizes="32x32">
<link rel="icon" href="./assets/favicon-57.png" sizes="57x57">
<link rel="icon" href="./assets/favicon-76.png" sizes="76x76">
<link rel="icon" href="./assets/favicon-96.png" sizes="96x96">
<link rel="icon" href="./assets/favicon-128.png" sizes="128x128">
<link rel="icon" href="./assets/favicon-192.png" sizes="192x192">
<link rel="icon" href="./assets/favicon-228.png" sizes="228x228">
<style>
body {
background-image: linear-gradient(#090B1A, #131524);
margin: 0;
padding: 0;
overflow-x: hidden;
}
</style>
<link href="https://fonts.googleapis.com/css?family=Droid+Sans|Oswald&display=swap" rel="stylesheet">
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<noscript>
This site requires JavaScript to run.
</noscript>
<script src="./dist/bundle.js"></script>
<script>
</script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@ -6,10 +6,10 @@ import 'core-js/features/number/is-nan';
/* App starts here */
import React from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Button from '@material-ui/core/Button';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import { Router, Route } from "react-router-dom";
//import 'typeface-roboto';
@ -22,6 +22,7 @@ function App() {
if (base) {
base = new URL(base).pathname;
}
console.log(`Base: ${base}`);
return (
<React.Fragment>
@ -30,10 +31,13 @@ function App() {
<Button color="inherit">Login</Button>
</Toolbar>
</AppBar>
<Router history={history}>
<Route exact path={base + 'games/:id?'} component={Board}/>
<Route exact path={base} component={Board}/>
</Router>
<BrowserRouter basename="/ketr.ketran">
<Routes history={history}>
<Route exact component={Board} path={base + 'games/:id?'}/>
<Route exact component={Board} path={base}/>
</Routes>
</BrowserRouter>
</React.Fragment>
);
}

View File

@ -1,17 +1,14 @@
import { createBrowserHistory } from 'history';
/*
// Run our app under the /base URL.
const history = createBrowserHistory(),
const history = createBrowserHistory({
basename: process.env.PUBLIC_URL
}),
push = history.push;
history.push = (path) => {
const base = new URL(document.querySelector("base") ? document.querySelector("base").href : "");
push(base.pathname + path);
};
*/
export default createBrowserHistory({
basename: process.env.PUBLIC_URL
});
//export default history;
export default history;