Skip to content

Commit ff05779

Browse files
committed
updated to handle wp subdirectory installations
1 parent e211e11 commit ff05779

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

bundle.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import axios from 'axios';
22

3+
export const SITEBASE = RT_API.baseUrl.replace(['http://','https://'],'').replace(window.location.origin.replace(['http://','https://'],''), '');
4+
35
export const FETCH_POSTS = 'FETCH_POSTS';
46
export const FETCH_POST = 'FETCH_POST';
57
export const SEARCH_POSTS = 'SEARCH_POSTS';

src/components/header.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import {Link} from 'react-router-dom';
44
import Menu from '../containers/parts/menu';
55
import Search from './search';
66

7+
import {SITEBASE} from '../actions';
8+
79
class Header extends Component {
810
render() {
11+
912
return (
1013
<header className="navbar navbar-expand-lg navbar-light bg-light">
11-
<h1 className="navbar-brand"><Link to='/'>{RT_API.siteName}</Link></h1>
14+
<h1 className="navbar-brand"><Link to={SITEBASE}>{RT_API.siteName}</Link></h1>
1215
<nav className="collapse navbar-collapse">
1316
<Menu name="main_menu" />
1417
<Search searchTerm={this.props.searchTerm} isSearch={this.props.isSearch} />

src/components/search.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, {Component} from 'react';
22
import {withRouter} from "react-router-dom";
33

4+
import {SITEBASE} from '../actions';
5+
46
class Search extends Component {
57
componentDidMount() {
68
if ( this.props.isSearch) {
@@ -15,9 +17,9 @@ class Search extends Component {
1517
event.preventDefault();
1618
const searchTerm = event.target.value;
1719
if (0 < searchTerm.length) {
18-
this.props.history.push(`/search/${searchTerm}`);
20+
this.props.history.push(`${SITEBASE}/search/${searchTerm}`);
1921
} else {
20-
this.props.history.push('/');
22+
this.props.history.push(`${SITEBASE}/`);
2123
}
2224
}
2325

src/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,21 @@ import Category from './containers/category';
3434
import Tag from './containers/tag';
3535
import Single from './containers/single';
3636

37+
import {SITEBASE} from './actions';
38+
3739
ReactDom.render(
3840
<Provider store={store}>
3941
<ConnectedRouter history={history}>
4042
<Switch>
41-
<Route exact path="/" component={Blog}/>
42-
<Route path="/page/:pageNum" component={Blog}/>
43-
<Route path="/search/:term" component={Search}/>
44-
<Route path="/category/:slug/page/:pageNum" component={Category}/>
45-
<Route path="/category/:slug/" component={Category}/>
46-
<Route path="/category/:parent/:slug/page/:pageNum" component={Category}/>
47-
<Route path="/category/:parent/:slug/" component={Category}/>
48-
<Route path="/tag/:slug/page/:pageNum" component={Tag}/>
49-
<Route path="/tag/:slug" component={Tag}/>
43+
<Route exact path={`${SITEBASE}/`} component={Blog}/>
44+
<Route path={`${SITEBASE}/page/:pageNum`} component={Blog}/>
45+
<Route path={`${SITEBASE}/search/:term`} component={Search}/>
46+
<Route path={`${SITEBASE}/category/:slug/page/:pageNum`} component={Category}/>
47+
<Route path={`${SITEBASE}/category/:slug`} component={Category}/>
48+
<Route path={`${SITEBASE}/category/:parent/:slug/page/:pageNum`} component={Category}/>
49+
<Route path={`${SITEBASE}/category/:parent/:slug`} component={Category}/>
50+
<Route path={`${SITEBASE}/tag/:slug/page/:pageNum`} component={Tag}/>
51+
<Route path={`${SITEBASE}/tag/:slug`} component={Tag}/>
5052
<Route path="*" component={Single}/>
5153
</Switch>
5254
</ConnectedRouter>

0 commit comments

Comments
 (0)