-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
64 lines (54 loc) · 2.14 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import './index.css';
//import App from './App';
import App from './pages/App';
import registerServiceWorker from './registerServiceWorker';
import firebase from 'firebase';
// Static Pages
import Home from './pages/Home';
import Services from './pages/Services';
import Appointments from './pages/Appointments';
import Page404 from './pages/Page404';
// Sign Up
import Signup1 from './signup/Step1';
import Signup2 from './signup/Step2';
import Signup3 from './signup/Step3';
// Page Title Logic
let pageMeta = { /* browser title, page header */
'/services': { title: 'Services', header: 'Services' },
'/appointments': { title: 'Appointments', header: 'Appointments' },
'/welcome': { title: 'Welcome', header: 'Welcome' },
'/welcome/2': { title: 'Welcome', header: 'Welcome' },
'/welcome/3': { title: 'Welcome', header: 'Welcome' },
default: { title: 'Welcome!', header: 'Welcome!' },
};
function updateTitle() {
let path = window.location.pathname;
// console.log(path);
if (!pageMeta[path]) {
// try to find a similar path that has a title and use it
for (path in pageMeta) {
if (window.location.pathname.indexOf(path) === 0) {
break;
}
}
if (!pageMeta[path]) { path = 'default'; }
}
document.getElementsByTagName('title')[0].innerText = 'On & On Wellness Spa - ' + pageMeta[path].header;
}
ReactDOM.render(
<Router onUpdate={() => window.scrollTo(0, 0)} history={browserHistory}>
<Route path='/' component={App}>
<IndexRoute component={Home} />
<Route path='/services' component={Services} onEnter={updateTitle} />
<Route path='/appointments' component={Appointments} onEnter={updateTitle} />
<Route path='/welcome' component={Signup1} onEnter={updateTitle} />
<Route path='/welcome/2' component={Signup2} onEnter={updateTitle} />
<Route path='/welcome/3' component={Signup3} onEnter={updateTitle} />
<Route path='*' component={Page404} onEnter={updateTitle} />
</Route>
</Router>
, document.getElementById('root'));
registerServiceWorker();