setting base href support for router

This commit is contained in:
Cássio Zen
2016-07-15 15:05:04 -03:00
parent 5d6eec28bb
commit e3643217de
8 changed files with 53 additions and 35 deletions

15
src/routing/history.js Normal file
View File

@ -0,0 +1,15 @@
import { createHistory } from 'history';
import { useRouterHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
const base = document.querySelector('base');
let history = useRouterHistory(createHistory)({
basename: base && base.href || ''
});
const syncHistory = (store) => {
history = syncHistoryWithStore(history, store);
};
export { syncHistory };
export default history;

17
src/routing/routes.js Normal file
View File

@ -0,0 +1,17 @@
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from '../containers/App';
import CollectionPage from '../containers/CollectionPage';
import EntryPage from '../containers/EntryPage';
import SearchPage from '../containers/SearchPage';
import NotFoundPage from '../containers/NotFoundPage';
export default (
<Route path="/" component={App}>
<IndexRoute component={CollectionPage}/>
<Route path="/collections/:name" component={CollectionPage}/>
<Route path="/collections/:name/entries/:slug" component={EntryPage}/>
<Route path="/search" component={SearchPage}/>
<Route path="*" component={NotFoundPage}/>
</Route>
);