Skip to content

Commit ca70f8e

Browse files
committed
Added error pages, removed unused import
1 parent 1970da3 commit ca70f8e

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

pages/_error.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import Link from 'next/link';
2+
import styles from '../styles/_error.module.css';
3+
4+
function Error({ statusCode }) {
5+
return (
6+
<div className={styles.errorContainer}>
7+
<div className={styles.centerContent}>
8+
<h1>
9+
Error
10+
</h1>
11+
12+
<p>
13+
There was an error loading this page.
14+
</p>
15+
</div>
16+
17+
<Link href="/">
18+
<a className={styles.button}>
19+
Go to Docs
20+
</a>
21+
</Link>
22+
</div>
23+
)
24+
}
25+
26+
Error.getInitialProps = ({ res, err }) => {
27+
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
28+
return { statusCode }
29+
}
30+
31+
export default Error;

pages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useRef } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import Head from 'next/head';
33
import { useRouter } from 'next/router';
44
import styles from '../styles/index.module.css';

styles/_error.module.css

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.errorContainer {
2+
width: 100vw;
3+
height: 100vh;
4+
5+
display: flex;
6+
flex-direction: column;
7+
align-items: center;
8+
justify-content: center;
9+
}
10+
11+
.centerContent {
12+
display: flex;
13+
flex-direction: row;
14+
align-items: center;
15+
}
16+
17+
.centerContent h1 {
18+
font-size: 2em;
19+
20+
border-right: solid 2px rgba(0, 0, 0, 0.1);
21+
22+
padding: 0 0.75rem 0 0;
23+
margin: 0;
24+
}
25+
26+
.centerContent p {
27+
font-size: 1em;
28+
29+
margin: 0;
30+
padding: 0 0 0 0.75rem;
31+
}
32+
33+
.button {
34+
cursor: pointer;
35+
36+
margin: 2rem 0 0 0;
37+
padding: 0.35rem 1rem;
38+
39+
font-size: 1.1rem;
40+
41+
border: solid 1px rgba(0, 0, 0, 0.2);
42+
border-radius: 0.25rem;
43+
outline: none;
44+
45+
transition: ease-in-out 0.12s;
46+
47+
text-decoration: none;
48+
}
49+
50+
.button:hover {
51+
background: rgba(0, 0, 0, 0.7);
52+
border: solid 1px transparent;
53+
54+
color: white;
55+
}

0 commit comments

Comments
 (0)