2019-02-19 22:06:00 +03:00
|
|
|
|
import React from 'react'
|
|
|
|
|
import {Heading} from '@primer/components'
|
|
|
|
|
import {redirectTrailingSlash} from '../docs/redirect'
|
|
|
|
|
|
|
|
|
|
export default class extends React.Component {
|
2019-02-19 22:23:04 +03:00
|
|
|
|
static getInitialProps(context) {
|
2019-02-19 22:51:16 +03:00
|
|
|
|
// redirect trailing slash URLs to "clean" ones without
|
2019-02-19 22:23:04 +03:00
|
|
|
|
return redirectTrailingSlash(context) || getErrorProps(context)
|
|
|
|
|
}
|
2019-02-19 22:06:00 +03:00
|
|
|
|
|
|
|
|
|
render() {
|
2019-02-19 23:46:55 +03:00
|
|
|
|
const {url, statusCode = 500} = this.props
|
2019-02-19 22:06:00 +03:00
|
|
|
|
return <>
|
|
|
|
|
<Heading>Whoops! That’s a {statusCode}.</Heading>
|
|
|
|
|
<p>
|
|
|
|
|
We couldn’t find anything at <code>{url}</code>.
|
2019-02-19 22:23:04 +03:00
|
|
|
|
{null && <>Have you tried <a href={`/css/search?q=${encodeURIComponent(url)}`}>searching</a>?</>}
|
2019-02-19 22:06:00 +03:00
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-19 22:23:04 +03:00
|
|
|
|
|
|
|
|
|
function getErrorProps({req, res, err}) {
|
|
|
|
|
const {statusCode} = err || res
|
|
|
|
|
return {statusCode, url: req.url}
|
|
|
|
|
}
|