forked from npm/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.js
50 lines (46 loc) · 1.54 KB
/
page.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
import React from 'react'
import {BaseStyles, themeGet, Box} from '@primer/react'
import {createGlobalStyle} from 'styled-components'
import Slugger from 'github-slugger'
import Header from './components/header'
import Sidebar from './components/sidebar'
import {SkipBox, SkipLink} from './components/skip-nav'
import {SKIP_TO_CONTENT_ID, SKIP_TO_SEARCH_ID} from './constants'
import {PageProvider} from './hooks/use-page'
import Layout from './layout'
const GlobalStyles = createGlobalStyle`
body {
color: ${themeGet('colors.fg.default')};
background-color: ${themeGet('colors.canvas.default')};
}
`
const PageElement = ({element, props}) => {
const page = {
pageContext: props.pageContext,
frontmatter: props.pageContext?.frontmatter || {},
location: props.location,
path: props.location.pathname,
slugger: new Slugger(),
}
return (
<BaseStyles>
<GlobalStyles />
<SkipBox>
<SkipLink href={`#${SKIP_TO_SEARCH_ID}`}>Skip to search</SkipLink>
<SkipLink href={`#${SKIP_TO_CONTENT_ID}`}>Skip to content</SkipLink>
</SkipBox>
<PageProvider value={page}>
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
<Header />
<Box sx={{zIndex: 0, display: 'flex', flex: '1 1 auto', flexDirection: 'row'}}>
<Box sx={{display: ['none', null, null, 'block']}}>
<Sidebar />
</Box>
<Layout>{element}</Layout>
</Box>
</Box>
</PageProvider>
</BaseStyles>
)
}
export default PageElement