2018-11-30 22:54:49 +03:00
|
|
|
import React from 'react'
|
|
|
|
import App, {Container} from 'next/app'
|
|
|
|
import {MDXProvider} from '@mdx-js/tag'
|
|
|
|
import Head from 'next/head'
|
|
|
|
import {withMDXLive} from 'mdx-live'
|
2018-12-05 03:21:15 +03:00
|
|
|
import {BaseStyles, Box, Flex, Link, theme} from '@primer/components'
|
2018-12-05 03:14:03 +03:00
|
|
|
import {SideNav, Header, IndexHero} from '../src/components'
|
2018-12-05 02:59:30 +03:00
|
|
|
import {rootPage} from '../src/utils'
|
2018-11-30 22:54:49 +03:00
|
|
|
|
2018-12-05 03:32:55 +03:00
|
|
|
import 'primer/build/build.css'
|
2018-12-05 02:47:22 +03:00
|
|
|
|
2018-11-30 22:54:49 +03:00
|
|
|
const components = {
|
|
|
|
// render links with our component
|
2018-12-05 00:54:53 +03:00
|
|
|
a: Link,
|
2018-11-30 22:54:49 +03:00
|
|
|
code: withMDXLive('pre'),
|
|
|
|
pre: props => props.children
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class MyApp extends App {
|
|
|
|
static async getInitialProps({Component, ctx}) {
|
|
|
|
let page = {}
|
|
|
|
|
|
|
|
if (Component.getInitialProps) {
|
|
|
|
page = await Component.getInitialProps(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return {page}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-12-05 00:57:50 +03:00
|
|
|
// strip the trailing slash
|
|
|
|
const pathname = this.props.router.pathname.replace(/\/$/, '')
|
2018-11-30 22:54:49 +03:00
|
|
|
const {Component, page} = this.props
|
|
|
|
|
2018-12-05 02:59:30 +03:00
|
|
|
const node = rootPage.first(node => node.path === pathname)
|
|
|
|
const meta = node ? node.meta : {}
|
2018-12-04 02:53:47 +03:00
|
|
|
|
2018-11-30 22:54:49 +03:00
|
|
|
return (
|
|
|
|
<BaseStyles style={{fontFamily: theme.fonts.normal}}>
|
|
|
|
<Container>
|
|
|
|
<Head>
|
2018-12-04 02:53:47 +03:00
|
|
|
<title>Primer CSS{meta.title ? ` / ${meta.title}` : null}</title>
|
2018-11-30 22:54:49 +03:00
|
|
|
</Head>
|
|
|
|
<Header />
|
|
|
|
<Flex display={['block', 'block', 'flex', 'flex']} flexDirection="row-reverse">
|
|
|
|
<Box width="100%">
|
2018-12-05 01:04:53 +03:00
|
|
|
{meta.hero ? <IndexHero /> : null}
|
|
|
|
<Box color="gray.9" maxWidth={1012} width="100%" my={6} mx="auto" px={6}>
|
|
|
|
<div className="markdown-body">
|
|
|
|
{meta.title ? <h1>{meta.title}</h1> : null}
|
|
|
|
<MDXProvider components={components}>
|
|
|
|
<Component {...page} />
|
|
|
|
</MDXProvider>
|
2018-12-05 03:14:03 +03:00
|
|
|
<pre>meta: {JSON.stringify(meta, null, 2)}</pre>
|
2018-12-05 01:04:53 +03:00
|
|
|
</div>
|
2018-12-04 02:53:47 +03:00
|
|
|
{/* TODO: bring back edit link! */}
|
2018-11-30 22:54:49 +03:00
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
<SideNav />
|
|
|
|
</Flex>
|
|
|
|
</Container>
|
|
|
|
</BaseStyles>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|