Skip to content

Commit 5c49024

Browse files
authored
Merge pull request #1 from mstrluke/development
Added Helmet to pages and fixed helmet renderer
2 parents e9e3eec + 4666c68 commit 5c49024

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Use it as you want.
1010
- Client Side Rendering
1111
- Isomorphyc Rendering
1212
- Hot Module Replacement
13+
- Webpack Dev Server
1314
- Code splitting
1415

1516
### Todo features
@@ -20,7 +21,6 @@ Use it as you want.
2021
- React Context API
2122
- API config
2223

23-
2424
### Installation
2525

2626
Clone and install the dependencies

src/pages/AboutPage/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { Helmet } from 'react-helmet'
34

45
const AboutPage = ({ history }) => {
56
const handleClick = () => {
@@ -8,6 +9,10 @@ const AboutPage = ({ history }) => {
89

910
return (
1011
<div>
12+
<Helmet>
13+
<title>About page | React SSR</title>
14+
<meta name="description" content="About page" />
15+
</Helmet>
1116
<p>About Page</p>
1217
<button onClick={handleClick}>Go to Home page</button>
1318
</div>

src/pages/HomePage/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { Helmet } from 'react-helmet'
4+
35

46
const HomePage = ({ history }) => {
57
const handleClick = () => {
@@ -8,6 +10,10 @@ const HomePage = ({ history }) => {
810

911
return (
1012
<div>
13+
<Helmet>
14+
<title>Home page | React SSR</title>
15+
<meta name="description" content="Home page" />
16+
</Helmet>
1117
<p>Home Page</p>
1218
<button onClick={handleClick}>Go to About page</button>
1319
</div>

src/pages/NotFoundPage/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Helmet } from 'react-helmet'
4+
5+
const NotFound = ({ history }) => {
6+
const handleClick = () => {
7+
history.push('/')
8+
}
9+
10+
return (
11+
<div>
12+
<Helmet>
13+
<title>404 Not Found Page | React SSR</title>
14+
<meta name="description" content="Not Found Page" />
15+
</Helmet>
16+
<p>404 Not Found Page</p>
17+
<button onClick={handleClick}>Go to Home page</button>
18+
</div>
19+
)
20+
}
21+
22+
NotFound.propTypes = {
23+
history: PropTypes.object
24+
}
25+
26+
export default NotFound;

src/routes/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import HomePage from '../pages/HomePage';
22
import AboutPage from '../pages/AboutPage';
3+
import NotFoundPage from '../pages/NotFoundPage';
34

45
export default [
56
{
@@ -13,5 +14,10 @@ export default [
1314
component: AboutPage,
1415
path: '/about',
1516
exact: true
17+
},
18+
{
19+
title: 'Not Found',
20+
component: NotFoundPage,
21+
exact: true
1622
}
1723
];

src/utils/template.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ const template = ({ css, scripts }, req, res) => {
2323
<link rel="icon" href="/favicon.ico" />
2424
<link rel="manifest" href="/manifest.webmanifest" />
2525
<meta name="viewport" content="width=device-width, initial-scale=1" />
26-
<meta name="description" content="Minimal SSR React App" />
27-
<meta name="theme-color" content="#000000" />
28-
<title>Minimal SSR React App</title>
2926
${helmet.title.toString()}
3027
${helmet.meta.toString()}
3128
${helmet.link.toString()}

0 commit comments

Comments
 (0)