Skip to content

Commit 460aac7

Browse files
committed
Update version handling
1 parent 6962b20 commit 460aac7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tools/docs/www/src/app.jsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Route, Switch, withRouter } from 'react-router-dom';
2323
import { Link } from 'react-router-dom';
2424
import SideMenu from './side_menu.jsx';
2525
import WelcomePage from './welcome_page.jsx';
26+
import VERSIONS from './versions.json';
2627
import './css/app.css';
2728
import './css/reset.css';
2829
import './css/highlight.css';
@@ -53,8 +54,13 @@ class App extends Component {
5354
constructor( props ) {
5455
super( props );
5556

56-
const pathname = props.history.location.pathname;
57-
const version = pathname.substring( 1, pathname.indexOf( '/docs' ) );
57+
let pathname = props.history.location.pathname;
58+
let version = pathname.substring( 1, pathname.indexOf( '/docs' ) );
59+
if ( !VERSIONS.includes( version ) ) {
60+
pathname = pathname.replace( version, VERSIONS[ 0 ] );
61+
this.props.history.push( pathname );
62+
version = VERSIONS[ 0 ];
63+
}
5864
this.state = {
5965
slideoutIsOpen: true,
6066
version: version,
@@ -239,7 +245,7 @@ class App extends Component {
239245
path="/:version/docs/api/@stdlib/:pkg*"
240246
render={this.renderReadme}
241247
/>
242-
<Route exact path="/:version/docs/api" >
248+
<Route exact path="/:version?" >
243249
<WelcomePage version={this.state.version} />
244250
</Route>
245251
</Switch>

tools/docs/www/src/side_menu.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class MenuBar extends Component {
270270
}}
271271
>
272272
<div className="side-menu-head" >
273-
<Link to={`/${this.props.version}/docs/api`}>
273+
<Link to={`/${this.props.version}`}>
274274
<Logo />
275275
</Link>
276276
<IconButton aria-label="close drawer" onClick={this.handleDrawerClose} edge="start" >

0 commit comments

Comments
 (0)