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'
import {BaseStyles, Box, Flex, Link, theme} from '@primer/components'
import {SideNav, Header, IndexHero} from '../src/components'
import {rootPage} from '../src/utils'
import 'primer/build/build.css'
import 'prism-github/prism-github.css'
export default class MyApp extends App {
static async getInitialProps({Component, ctx}) {
let page = {}
if (Component.getInitialProps) {
page = await Component.getInitialProps(ctx)
}
return {page}
}
render() {
// strip the trailing slash
const pathname = this.props.router.pathname.replace(/\/$/, '')
const {Component, page} = this.props
const node = rootPage.first(node => node.path === pathname)
const {meta = {}, outline: getOutline = () => []} = node || {}
const components = {
// render links with our component
a: Link,
p: ({children, ...rest}) => {
if (children === '{:toc}') {
return
{children}
} }, code: withMDXLive('pre'), pre: props => props.children } return (meta: {JSON.stringify(meta, null, 2)}