added basename to router
- this enables the app to be hosted from a subdomain in production
This commit is contained in:
parent
09d3af688b
commit
a9a607efd1
@ -1,12 +1,10 @@
|
||||
import React from 'react'
|
||||
import {connect} from 'react-redux'
|
||||
import { connect } from 'react-redux'
|
||||
import { Navbar, Nav, NavDropdown, FormControl, Form, Button } from 'react-bootstrap'
|
||||
import {LinkContainer} from 'react-router-bootstrap'
|
||||
import {NavLink} from 'react-router-dom'
|
||||
import { NavLink } from 'react-router-dom'
|
||||
|
||||
const MainNav = (props) => {
|
||||
const {episodes, captions} = props
|
||||
|
||||
const { episodes } = props
|
||||
return (
|
||||
<Navbar bg="dark" variant="dark" expand="lg">
|
||||
<Navbar.Brand href="/">Anarchy Planet</Navbar.Brand>
|
||||
@ -20,7 +18,7 @@ const MainNav = (props) => {
|
||||
</NavLink>
|
||||
)}
|
||||
</NavDropdown>
|
||||
<Nav.Link href="/audio">Player</Nav.Link>
|
||||
<NavLink className="navbar-nav" to="/audio">Player</NavLink>
|
||||
</Nav>
|
||||
|
||||
<Form inline>
|
||||
|
@ -2,6 +2,8 @@ const createHistory = require('history').createBrowserHistory
|
||||
const createMemoryHistory = require('history').createMemoryHistory
|
||||
|
||||
const history =
|
||||
process.env.NODE_ENV === 'test' ? createMemoryHistory() : createHistory()
|
||||
process.env.NODE_ENV === 'test'
|
||||
? createMemoryHistory()
|
||||
: createHistory()
|
||||
|
||||
export default history
|
||||
|
@ -1,15 +1,14 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import {Provider} from 'react-redux'
|
||||
import {Router} from 'react-router-dom'
|
||||
import { Provider } from 'react-redux'
|
||||
import { BrowserRouter as Router } from 'react-router-dom'
|
||||
import history from './history'
|
||||
import store from './store'
|
||||
import App from './app'
|
||||
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<Router history={history}>
|
||||
<Router basename="/waveform" history={history}>
|
||||
<App />
|
||||
</Router>
|
||||
</Provider>,
|
||||
|
@ -1,29 +1,31 @@
|
||||
import React, {Component} from 'react'
|
||||
import {withRouter, Route} from 'react-router-dom'
|
||||
import {connect} from 'react-redux'
|
||||
import {Episodes} from './components/episodes'
|
||||
import {Captions} from './components/captions'
|
||||
import React, { Component } from 'react'
|
||||
import { withRouter, Route } from 'react-router-dom'
|
||||
import { connect } from 'react-redux'
|
||||
import { Episodes } from './components/episodes'
|
||||
import { Captions } from './components/captions'
|
||||
import Audio from './components/waveform'
|
||||
import Main from './components'
|
||||
class Routes extends Component {
|
||||
componentDidMount() {
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Route exact path="/" component = {Main} />
|
||||
<Route path="/episodes" component={Episodes} />
|
||||
<Route path="/captions/:slug" component={Captions} />
|
||||
<Route path="/audio" component={Audio} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
import { Main, Navbar } from './components'
|
||||
import { Login, Signup } from './components/auth-form'
|
||||
|
||||
const Routes = () => {
|
||||
return (
|
||||
<div>
|
||||
<Route path="/login" component={Login} />
|
||||
<Route path="/signup" component={Signup} />
|
||||
<Route path='/navbar' component={Navbar} />
|
||||
<Route exact path='/' component={Main} />
|
||||
<Route path='/episodes' component={Episodes} />
|
||||
<Route path='/captions/:slug' component={Captions} />
|
||||
<Route path='/audio' component={Audio} />
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
const mapState = state => {
|
||||
return {
|
||||
episodes: state.episodes,
|
||||
captions: state.captions
|
||||
captions: state.captions,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,10 @@ const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
entry: ['@babel/polyfill', './src/index.js'],
|
||||
output: {
|
||||
path: path.resolve(__dirname, '/dist'),
|
||||
filename: 'bundle.js',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
@ -15,10 +19,6 @@ module.exports = {
|
||||
resolve: {
|
||||
extensions: ['*', '.js', '.jsx'],
|
||||
},
|
||||
output: {
|
||||
path: __dirname + '/dist',
|
||||
filename: 'bundle.js',
|
||||
},
|
||||
plugins: [new webpack.HotModuleReplacementPlugin()],
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'dist'),
|
||||
|
Loading…
Reference in New Issue
Block a user