-
Notifications
You must be signed in to change notification settings - Fork 8
/
_app.js
60 lines (55 loc) · 1.43 KB
/
_app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// @flow
import * as React from 'react';
import { Box } from 'react-system';
import { Layout, Code, Stack, Markdown, MenuLink } from '../dev-src/controls';
import type { Doc } from '../dev-src/doc';
type Props = {|
pageDocs?: $ReadOnlyArray<Doc>,
|};
const App = ({
Component,
pageProps,
router,
}: {
Component: React.AbstractComponent<{||}>,
pageProps: Props,
router: {| pathname: string, basePath: string |},
}): React.Node => {
const pathname = router.pathname.replace(router.basePath, '');
const doc = pageProps.pageDocs?.find(pd => pathname === pd.pathname) ?? null;
return (
<Layout
nav={
<>
<Box as="h3" mb="0.75rem">
Examples
</Box>
{pageProps.pageDocs
?.filter(d => d.order < 100)
.map(d => (
<MenuLink key={d.pathname} href={d.pathname}>
{d.title}
</MenuLink>
))}
<Box as="h3" mb="0.75rem" mt="2rem">
Tests
</Box>
{pageProps.pageDocs
?.filter(d => d.order >= 100)
.map(d => (
<MenuLink key={d.pathname} href={d.pathname}>
{d.title}
</MenuLink>
))}
</>
}
>
<Stack>
{doc && <Markdown>{doc.markdown}</Markdown>}
<Component />
{doc && <Code>{doc.source}</Code>}
</Stack>
</Layout>
);
};
export default App;