Skip to content

Commit ef6e98b

Browse files
sveinpgmarkerikson
authored andcommitted
Add custom 404 page (#53)
1 parent 62bf417 commit ef6e98b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

website/pages/en/404.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const React = require("react");
2+
const siteConfig = require(`${process.cwd()}/siteConfig.js`);
3+
4+
class ErrorPage extends React.Component {
5+
getTrackingScript() {
6+
if (!siteConfig.gaTrackingId) {
7+
return null;
8+
}
9+
10+
return {__html:`
11+
ga('create', "${siteConfig.gaTrackingId}");
12+
ga('send', {
13+
hitType: 'event',
14+
eventCategory: '404 Response',
15+
eventAction: window.location.href,
16+
eventLabel: document.referrer
17+
});`
18+
}
19+
}
20+
21+
render() {
22+
const trackingScript = this.getTrackingScript();
23+
24+
return (
25+
<div className="error-page">
26+
{trackingScript && <script dangerouslySetInnerHTML={trackingScript}/>}
27+
<div className="error-message">
28+
<div className=" error-message-container container">
29+
<span>404 </span>
30+
<p>Page Not Found.</p>
31+
<a href="/">Return to the front page</a>
32+
</div>
33+
</div>
34+
</div>
35+
);
36+
}
37+
}
38+
39+
ErrorPage.title = "Page Not Found"
40+
41+
42+
module.exports = ErrorPage;

website/static/css/404.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.error-page .error-message-container {
2+
margin-left: auto;
3+
margin-right: auto;
4+
padding-top: 40px;
5+
max-width: 1400px;
6+
width: 87%;
7+
}
8+
.error-page .error-message {
9+
min-height: 90vh;
10+
background: white;
11+
}
12+
.error-page .error-message span {
13+
color: #764ABC;
14+
font-size: 8.8em;
15+
font-weight: 700;
16+
display: inline-block;
17+
margin-top: 10vh;
18+
text-align: center;
19+
display: block;
20+
}
21+
.error-page .error-message p {
22+
color: black;
23+
margin-top: 50px;
24+
font-size: 1.6em;
25+
text-align: center;
26+
}
27+
28+
.error-page .error-message a {
29+
margin-bottom: 50px;
30+
font-size: 1.6em;
31+
text-align: center;
32+
display: block;
33+
text-decoration: underline;
34+
}

0 commit comments

Comments
 (0)