-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathpage.js
More file actions
68 lines (63 loc) · 1.82 KB
/
Copy pathpage.js
File metadata and controls
68 lines (63 loc) · 1.82 KB
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
61
62
63
64
65
66
67
68
import React from 'react'
import {BaseStyles} 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,
HEADER_HEIGHT,
HEADER_BAR,
FULL_HEADER_HEIGHT,
SCROLL_MARGIN_TOP,
Z_INDEX,
} from './constants'
import {PageProvider} from './hooks/use-page'
import Layout from './layout'
import * as styles from './page.module.css'
const GlobalStyles = createGlobalStyle`
:root {
--header-height: ${HEADER_HEIGHT}px;
--header-bar: ${HEADER_BAR}px;
--full-header-height: ${FULL_HEADER_HEIGHT}px;
--scroll-margin-top: ${SCROLL_MARGIN_TOP}px;
--z-index-header: ${Z_INDEX.HEADER};
--z-index-search-overlay: ${Z_INDEX.SEARCH_OVERLAY};
}
body {
color: var(--fgColor-default);
background-color: var(--bgColor-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}>
<div className={styles.Box}>
<Header />
<div className={styles.Box_1}>
<div className={styles.sidebarContainer}>
<Sidebar />
</div>
<Layout>{element}</Layout>
</div>
</div>
</PageProvider>
</BaseStyles>
)
}
export default PageElement