-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
51 lines (46 loc) · 1.51 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import { IndexRoute, Route } from 'react-router';
import App from './App';
import Home from './src/containers/Home';
import Photos from './src/containers/Photos';
import Rebates from './src/containers/Rebates';
import Articles from './src/containers/Articles';
import Profile from './src/containers/Profile';
import PhotosDetails from './src/containers/PhotoDetails.js';
function setPageTitle(nextState) {
let pageTitle = '';
let pathName = nextState.location.pathname || '';
pathName = pathName.replace('/','');
switch (pathName) {
case 'photos':
pageTitle = 'Get Inspired';
break;
case 'rebates':
pageTitle = 'Start Saving';
break;
case 'articles':
pageTitle = 'Expert Insight';
break;
case 'profile':
pageTitle = 'Your Rise Profile';
break;
}
if (document) {
document.title = `Rise ${pageTitle} | Your Home, Built With Purpose`;
}
}
function onPageEnter(nextState) {
setPageTitle(nextState);
}
export default (
<Route path="/" component={App} >
<IndexRoute component={Home} onEnter = {onPageEnter} />
<Route path="photos" onEnter = {onPageEnter} >
<IndexRoute component={Photos} onEnter = {onPageEnter} />
<Route path=":photoId" component={PhotosDetails} />
</Route>
<Route path="rebates" component={Rebates} onEnter = {onPageEnter} />
<Route path="articles" component={Articles} onEnter = {onPageEnter} />
<Route path="profile" component={Profile} onEnter = {onPageEnter} />
</Route>
)