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