Skip to content

Commit 15da349

Browse files
skvalegreg-a-smith
authored andcommitted
fix: Playground: Add a 404.html identical to index.html (#398)
* fix(playground): Add a 404 route. cp index.html to 404.html. Github pages hosting will automatically route to 404.html * fix(playground): Rephrase 404 message, move cp 404.html to build-doc
1 parent f428ff4 commit 15da349

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"scripts": {
1414
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
15-
"build-doc": "node scripts/build.js",
15+
"build-doc": "node scripts/build.js && cp build/index.html build/404.html",
1616
"build-js": "node scripts/build.js",
1717
"build:lint:fix": "eslint --fix 'src/**' --ext .js,.jsx --env browser,node",
1818
"build:lint": "eslint 'src/**' --ext .js,.jsx --env browser,node",

src/_playground/Routes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { DatePickerComponent } from '../DatePicker/DatePicker.Component';
1010
import { DropdownComponent } from '../Dropdown/Dropdown.Component';
1111
import { FormsComponent } from '../Forms/Forms.Component';
1212
import groupArray from 'group-array';
13+
import { Header } from './documentation/Header/Header';
1314
import { Home } from './documentation/Home/Home';
1415
import { IconComponent } from '../Icon/Icon.Component';
1516
import { IdentifierComponent } from '../Identifier/Identifier.Component';
@@ -37,7 +38,7 @@ import { TimePickerComponent } from '../TimePicker/TimePicker.Component';
3738
import { ToggleComponent } from '../Toggle/Toggle.Component';
3839
import { TokenComponent } from '../Token/Token.Component';
3940
import { TreeComponent } from '../Tree/Tree.Component';
40-
import { BrowserRouter, NavLink, Redirect, Route, Switch } from 'react-router-dom';
41+
import { BrowserRouter, Link, NavLink, Redirect, Route, Switch } from 'react-router-dom';
4142

4243
const sections = [
4344
{
@@ -270,6 +271,13 @@ const routes = [
270271
}
271272
];
272273

274+
const RouteNotFound = () => (
275+
<div>
276+
<Header>Sorry, page not found.</Header>
277+
<Link to=''>Home</Link>
278+
</div>
279+
);
280+
273281
export const Routes = () => {
274282
let sectionRoutes;
275283
const groupedRoutes = groupArray(routes, 'section');
@@ -320,6 +328,7 @@ export const Routes = () => {
320328
})}
321329
<Redirect exact from=''
322330
to='/home' />
331+
<Route component={RouteNotFound} />
323332
</Switch>
324333
</div>
325334
</div>

0 commit comments

Comments
 (0)