-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathPage.tsx
119 lines (112 loc) · 3.33 KB
/
Page.tsx
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/** @jsxImportSource @emotion/react */
'use client'
import { useRef, Fragment, type ReactNode } from 'react'
import { usePathname } from 'next/navigation'
import { useMediaQuery } from '../lib/media'
import { TableOfContents } from './docs/TableOfContents'
import { Wrapper } from './primitives/Wrapper'
import { EditButton } from './primitives/EditButton'
import { Breadcrumbs } from './Breadcrumbs'
import { Stack } from './primitives/Stack'
import { Header } from './Header'
import { Footer } from './Footer'
import { type HeadingType } from './Markdoc'
export function BlogPage({
children,
headings = [],
noRightNav,
isIndexPage,
editPath,
}: {
children: ReactNode
headings?: HeadingType[]
noRightNav?: boolean
isIndexPage?: boolean
editPath?: string
}) {
const contentRef = useRef<HTMLDivElement | null>(null)
const mq = useMediaQuery()
const pathname = usePathname()
return (
<div
css={{
gridArea: 'main',
position: 'relative',
display: 'grid',
gridTemplateRows: '4.5rem calc(100vh - 4.5rem)',
}}
>
<Header />
<Wrapper
css={mq({
borderTop: '1px solid var(--border)',
overflowY: 'auto',
display: ['block', null, 'grid'],
margin: '0 auto 0',
paddingLeft: ['var(--space-xlarge)', 'var(--space-xlarge)', null, '7.5rem'],
paddingRight: ['var(--space-xlarge)', 'var(--space-xlarge)', null, '7.5rem'],
gridTemplateRows: '1fr auto',
gap: ['var(--space-medium)', null, null, 'var(--space-large)', 'var(--space-xlarge)'],
})}
>
<div
id="content-and-toc"
css={mq({
gridColumn: '2 / 3',
gridRow: '1 / 2',
display: ['block', null, 'grid'],
gridTemplateColumns: noRightNav
? 'minmax(0, 1fr)'
: ['minmax(0, 1fr)', null, null, 'minmax(0, 1fr) 10rem', 'minmax(0, 1fr) 15rem'],
gap: ['var(--space-medium)', null, null, 'var(--space-large)', 'var(--space-xlarge)'],
})}
>
<main
id="skip-link-content"
tabIndex={0}
ref={contentRef}
className={'prose'}
css={{
paddingTop: '2rem',
}}
>
<Stack
orientation="horizontal"
block
css={{ justifyContent: 'space-between', alignItems: 'baseline' }}
>
<Breadcrumbs />
<EditButton pathName={pathname || ''} isIndexPage={isIndexPage} editPath={editPath} />
</Stack>
<div id="content" css={{ display: 'grid', gridTemplateColumns: 'minmax(0, 1fr)' }}>
{children}
</div>
</main>
{!!headings.length && !noRightNav && (
<TableOfContents container={contentRef} headings={headings} />
)}
</div>
<Footer />
</Wrapper>
</div>
)
}
export function Page({ children }: { children: ReactNode }) {
return (
<Fragment>
<div
css={{
gridArea: 'main',
position: 'relative',
paddingBottom: 'var(--space-xxlarge)',
}}
>
<Header />
<Wrapper as="main" id="skip-link-content" tabIndex={0}>
{children}
</Wrapper>
</div>
<Footer />
</Fragment>
)
}