forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPage.tsx
More file actions
202 lines (193 loc) · 5.46 KB
/
Copy pathPage.tsx
File metadata and controls
202 lines (193 loc) · 5.46 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/** @jsxRuntime classic */
/** @jsx jsx */
import { useRef, Fragment, ReactNode } from 'react';
import { useRouter } from 'next/router';
import { jsx } from '@emotion/react';
import Head from 'next/head';
import Link from 'next/link';
import { useMediaQuery } from '../lib/media';
import type { Heading } from '../lib/getHeadings';
import { Announce } from '../components/Announce';
import { TableOfContents } from './docs/TableOfContents';
import { Wrapper } from './primitives/Wrapper';
import { EditButton } from './primitives/EditButton';
// import { Emoji } from './primitives/Emoji';
import { Breadcrumbs } from './Breadcrumbs';
import { Sidebar } from './docs/Sidebar';
import { Stack } from './primitives/Stack';
import { Header } from './Header';
import { Footer } from './Footer';
function Announcement() {
// special announcement
// return (
// <Announce>
// <Emoji symbol="🎤" alt="Microphone" />{' '}
// <a
// href="https://306ucv95ugh.typeform.com/to/TbFERbep"
// rel="noopener noreferrer"
// target="_blank"
// >
// Join us
// </a>{' '}
// for our first <strong>Community Q&A</strong> next{' '}
// <strong>Tuesday Sep 21st @ 3–4pm AEST</strong> –{' '}
// <a
// href="https://306ucv95ugh.typeform.com/to/TbFERbep"
// rel="noopener noreferrer"
// target="_blank"
// >
// Register now
// </a>
// !
// </Announce>
// );
// standard announcement
return (
<Announce>
<strong>
Keystone 6 is now in <Link href="/updates/general-availability">General Availability</Link>!
</strong>
</Announce>
);
}
function OpenGraph({
title,
description,
ogImage,
}: {
title: string;
description: string;
ogImage?: string;
}) {
const siteUrl = process.env.siteUrl;
if (!ogImage) {
ogImage = `${siteUrl}/og-image-landscape.png`;
}
return (
<Head>
<title>{title}</title>
<meta name="description" content={description} />
<meta key="og:site_name" property="og:site_name" content={title} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={`${ogImage}`} />
<meta property="og:image:width" content="761" />
<meta property="og:image:height" content="410" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={`${ogImage}`} />
</Head>
);
}
export function DocsPage({
children,
headings = [],
noProse,
noRightNav,
title,
description,
ogImage,
isIndexPage,
editPath,
}: {
children: ReactNode;
headings?: Heading[];
noProse?: boolean;
noRightNav?: boolean;
title: string;
description: string;
ogImage?: string;
isIndexPage?: boolean;
editPath?: string;
}) {
const contentRef = useRef<HTMLDivElement | null>(null);
const mq = useMediaQuery();
const { pathname } = useRouter();
const isUpdatesPage = pathname.startsWith('/releases') || pathname.startsWith('/updates');
const metaTitle = title ? `${title} - Keystone 6 Documentation` : `Keystone 6 Documentation`;
return (
<Fragment>
<OpenGraph title={metaTitle} description={description} ogImage={ogImage} />
<div
css={{
gridArea: 'main',
position: 'relative',
paddingBottom: 'var(--space-xxlarge)',
}}
>
<Announcement />
<Header />
<Wrapper
css={mq({
display: ['block', null, 'grid'],
marginTop: '2.5rem',
gridTemplateColumns: noRightNav
? '15rem minmax(0, auto)'
: [
'15rem minmax(0, auto)',
null,
null,
'10rem minmax(0, auto) 10rem',
'15rem minmax(0, auto) 15rem',
],
gap: ['var(--space-medium)', null, null, 'var(--space-large)', 'var(--space-xlarge)'],
})}
>
<Sidebar isUpdatesPage={isUpdatesPage} />
<main
id="skip-link-content"
tabIndex={0}
ref={contentRef}
className={noProse ? '' : 'prose'}
>
<Stack
orientation="horizontal"
block
css={{ justifyContent: 'space-between', alignItems: 'baseline' }}
>
<Breadcrumbs />
<EditButton pathName={pathname} isIndexPage={isIndexPage} editPath={editPath} />
</Stack>
{children}
</main>
{!!headings.length && !noRightNav && (
<TableOfContents container={contentRef} headings={headings} />
)}
</Wrapper>
</div>
<Footer />
</Fragment>
);
}
export function Page({
children,
title,
description,
ogImage,
}: {
children: ReactNode;
title: string;
description: string;
ogImage?: string;
}) {
const metaTitle = title ? `${title} - Keystone 6` : `Keystone 6`;
return (
<Fragment>
<OpenGraph title={metaTitle} description={description} ogImage={ogImage} />
<div
css={{
gridArea: 'main',
position: 'relative',
paddingBottom: 'var(--space-xxlarge)',
}}
>
<Announcement />
<Header />
<Wrapper as="main" id="skip-link-content" tabIndex={0}>
{children}
</Wrapper>
</div>
<Footer />
</Fragment>
);
}