mirror of https://github.com/MaxLeiter/Drift
client: improve error page design, fix isPageRequest regex in middleware
parent
2a9e7ba6fc
commit
bc6362e412
@ -0,0 +1,19 @@
|
||||
import { Page } from '@geist-ui/core'
|
||||
|
||||
const Error = ({ status }: {
|
||||
status: number
|
||||
}) => {
|
||||
return (
|
||||
<Page title={status.toString() || 'Error'}>
|
||||
{status === 404 ? (
|
||||
<h1>This page cannot be found.</h1>
|
||||
) : (
|
||||
<section>
|
||||
<p>An error occurred: {status}</p>
|
||||
</section>
|
||||
)}
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
export default Error
|
||||
@ -0,0 +1,17 @@
|
||||
import ErrorComponent from '@components/error'
|
||||
|
||||
function Error({ statusCode }: {
|
||||
statusCode: number
|
||||
}) {
|
||||
return <ErrorComponent status={statusCode} />
|
||||
}
|
||||
|
||||
Error.getInitialProps = ({ res, err }: {
|
||||
res: any
|
||||
err: any
|
||||
}) => {
|
||||
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
|
||||
return { statusCode }
|
||||
}
|
||||
|
||||
export default Error
|
||||
Loading…
Reference in New Issue