mirror of
https://github.com/primer/css.git
synced 2024-12-01 04:21:12 +03:00
27 lines
790 B
JavaScript
27 lines
790 B
JavaScript
import React from 'react'
|
||
import {Heading} from '@primer/components'
|
||
import {redirectTrailingSlash} from '@primer/blueprints'
|
||
|
||
export default class extends React.Component {
|
||
static getInitialProps(context) {
|
||
// redirect trailing slash URLs to "clean" ones without
|
||
return redirectTrailingSlash(context) || getErrorProps(context)
|
||
}
|
||
|
||
render() {
|
||
const {url, statusCode = 500} = this.props
|
||
return <>
|
||
<Heading>Whoops! That’s a {statusCode}.</Heading>
|
||
<p>
|
||
We couldn’t find anything at <code>{url}</code>.
|
||
{null && <>Have you tried <a href={`/css/search?q=${encodeURIComponent(url)}`}>searching</a>?</>}
|
||
</p>
|
||
</>
|
||
}
|
||
}
|
||
|
||
function getErrorProps({req, res, err}) {
|
||
const {statusCode} = err || res
|
||
return {statusCode, url: req.url}
|
||
}
|