60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
/**
|
||
* Copyright (C) 2019-2021 Carl Kittelberger <icedream@icedream.pw>
|
||
*
|
||
* This program is free software: you can redistribute it and/or modify
|
||
* it under the terms of the GNU Affero General Public License as
|
||
* published by the Free Software Foundation, either version 3 of the
|
||
* License, or (at your option) any later version.
|
||
*
|
||
* This program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU Affero General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU Affero General Public License
|
||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
*/
|
||
|
||
import { NextPage } from 'next';
|
||
import { ErrorProps } from 'next/error';
|
||
import Head from 'next/head';
|
||
import * as React from 'react';
|
||
import { useIntl } from 'react-intl';
|
||
|
||
const Error: NextPage<ErrorProps> = ({
|
||
statusCode,
|
||
title,
|
||
}) => {
|
||
const intl = useIntl();
|
||
return (
|
||
<div>
|
||
<Head>
|
||
<title>
|
||
{title}
|
||
{' '}
|
||
–
|
||
{' '}
|
||
{intl.formatMessage({
|
||
id: 'App.title',
|
||
description: 'The full title of the website',
|
||
defaultMessage: 'Games Done Quick Instant Archive',
|
||
})}
|
||
</title>
|
||
<link rel="icon" href="/favicon.ico" />
|
||
</Head>
|
||
<p>
|
||
<h1>{statusCode} {title}</h1>
|
||
</p>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
Error.getInitialProps = (ctx) => {
|
||
const { res, err } = ctx;
|
||
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
|
||
const title = res ? res.statusMessage : err ? err.message : "Page not found";
|
||
return { statusCode, title }
|
||
}
|
||
|
||
export default Error
|