1
1
mirror of https://github.com/primer/css.git synced 2024-11-13 08:04:16 +03:00

docs: add bundle redirect page

This commit is contained in:
Shawn Allen 2019-02-12 11:19:59 -08:00
parent 6951aa2df3
commit 9fac57a3a6

18
pages/css/bundle.js Normal file
View File

@ -0,0 +1,18 @@
import {rootPage} from '../../docs/utils'
export default class {
static getInitialProps({query: {name}, res}) {
const url = getBundleURL(name)
if (url) {
res.writeHead(303, {Location: url})
} else {
res.writeHead(404)
}
res.end()
}
}
function getBundleURL(bundle) {
const node = rootPage.first(node => node.meta.bundle === bundle)
return node ? node.path : `/_error`
}