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:
parent
6951aa2df3
commit
9fac57a3a6
18
pages/css/bundle.js
Normal file
18
pages/css/bundle.js
Normal 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`
|
||||
}
|
Loading…
Reference in New Issue
Block a user