-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
87 lines (82 loc) · 1.71 KB
/
App.jsx
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
import { Link } from 'react-router-dom';
import Helmet from "react-helmet";
import homepageStyles from './homepage.scss';
class Menu extends Component {
render() {
return (
<div>
<ul>
<li>
<Link to={'/'}>Homepage</Link>
</li>
<li>
<Link to={'/about'}>About</Link>
</li>
<li>
<Link to={'/contact'}>Contact</Link>
</li>
</ul>
</div>
);
}
}
class Homepage extends Component {
render() {
return (
<div className={ homepageStyles.component }>
<Helmet title="測試 Homepage" />
<Menu />
<h1>Homepage</h1>
</div>
);
}
}
class About extends Component {
render() {
return (
<div>
<Helmet title="測試 About" />
<Menu />
<h1>About</h1>
</div>
);
}
}
class Contact extends Component {
render() {
return (
<div>
<Helmet title="測試 Contact" />
<Menu />
<h1>Contact</h1>
</div>
);
}
}
export default class App extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<Helmet
htmlAttributes={ { lang: "en", amp: undefined } } // amp takes no value
titleTemplate="%s | React App SSR"
titleAttributes={ { itemprop: "name", lang: "en" } }
meta={ [
{ name: "description", content: "React 使用 React Router v4,React Helmet和CSS模塊伺服器渲染(SSR) 範例" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
] }
/>
<Switch>
<Route exact path='/' component={ Homepage } />
<Route path="/about" component={ About } />
<Route path="/contact" component={ Contact } />
</Switch>
</div>
);
}
}