@graphcommerce/docs 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -0
- package/CHANGELOG.md +160 -0
- package/components/Layout/LayoutFull.tsx +85 -0
- package/components/Layout/Logo.tsx +19 -0
- package/components/Layout/graphcommerce.svg +34 -0
- package/components/Search.tsx +37 -0
- package/components/SearchForm.tsx +110 -0
- package/components/SidebarMenu/index.tsx +101 -0
- package/components/prism.css +274 -0
- package/components/rehype-prism-plus.css +49 -0
- package/components/theme.ts +410 -0
- package/content/framework/deployment.md +56 -0
- package/content/framework/environment-variables.md +61 -0
- package/content/framework/favicon.md +38 -0
- package/content/framework/graphcms.md +66 -0
- package/content/framework/icons.md +255 -0
- package/content/framework/readme.md +79 -0
- package/content/framework/seo.md +64 -0
- package/content/framework/static-file-serving.md +44 -0
- package/content/framework/static-generation.md +221 -0
- package/content/framework/theming.md +258 -0
- package/content/framework/translations.md +112 -0
- package/content/framework/troubleshooting.md +67 -0
- package/content/framework/typography.md +143 -0
- package/content/getting-started/create.md +152 -0
- package/content/getting-started/graphcms-component.md +240 -0
- package/content/getting-started/header.md +224 -0
- package/content/getting-started/pages.md +290 -0
- package/content/getting-started/readme.md +294 -0
- package/content/getting-started/start-building.md +160 -0
- package/content/getting-started/vscode.md +48 -0
- package/content/readme.md +124 -0
- package/content/roadmap.md +31 -0
- package/lib/DocumentIndexer.ts +59 -0
- package/lib/files.ts +168 -0
- package/lib/instantSearch.ts +26 -0
- package/lib/typesense/IndexerHandler.ts +47 -0
- package/lib/typesense/Leaves.ts +37 -0
- package/lib/typesense/SearchIndexer.ts +64 -0
- package/lib/typesense/batchInterable.ts +13 -0
- package/lib/typesense/createInstantSearchProps.ts +36 -0
- package/lib/typesense/typesenseClientConf.ts +23 -0
- package/lib/typesense/typesenseIndexerHandler.ts +23 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +21 -0
- package/package.json +56 -0
- package/pages/[[...url]].tsx +391 -0
- package/pages/_app.tsx +26 -0
- package/pages/_document.tsx +22 -0
- package/pages/api/reindex.ts +4 -0
- package/pages/menu/[[...url]].tsx +69 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +12 -0
- package/public/link.svg +4 -0
- package/public/manifest/favicon-192.png +0 -0
- package/public/manifest/favicon-512.png +0 -0
- package/public/manifest.webmanifest +20 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { PageOptions } from '@graphcommerce/framer-next-pages'
|
|
2
|
+
import { PageMeta } from '@graphcommerce/next-ui'
|
|
3
|
+
import {
|
|
4
|
+
Container,
|
|
5
|
+
Divider,
|
|
6
|
+
Typography,
|
|
7
|
+
Link,
|
|
8
|
+
alpha,
|
|
9
|
+
Table,
|
|
10
|
+
TableBody,
|
|
11
|
+
TableRow,
|
|
12
|
+
TableHead,
|
|
13
|
+
TableCell,
|
|
14
|
+
TableContainer,
|
|
15
|
+
Paper,
|
|
16
|
+
darken,
|
|
17
|
+
Box,
|
|
18
|
+
} from '@mui/material'
|
|
19
|
+
import { GetStaticPaths, GetStaticProps } from 'next'
|
|
20
|
+
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'
|
|
21
|
+
import { serialize } from 'next-mdx-remote/serialize'
|
|
22
|
+
import PageLink from 'next/link'
|
|
23
|
+
import { useRouter } from 'next/router'
|
|
24
|
+
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
|
|
25
|
+
import rehypePrism from 'rehype-prism-plus'
|
|
26
|
+
import rehypeSlug from 'rehype-slug'
|
|
27
|
+
import remarkGfm from 'remark-gfm'
|
|
28
|
+
import { SetRequired } from 'type-fest'
|
|
29
|
+
import { LayoutFull, LayoutFullProps } from '../components/Layout/LayoutFull'
|
|
30
|
+
import {
|
|
31
|
+
getDirectoryPaths,
|
|
32
|
+
getDirectoryTree,
|
|
33
|
+
getFileContents,
|
|
34
|
+
MatterFields,
|
|
35
|
+
urlToPath,
|
|
36
|
+
} from '../lib/files'
|
|
37
|
+
|
|
38
|
+
type MDXSource = SetRequired<MDXRemoteSerializeResult, 'frontmatter'>
|
|
39
|
+
type Props = { source: MDXSource } & LayoutFullProps
|
|
40
|
+
type Param = { url: string[] }
|
|
41
|
+
type GetStatic = GetStaticProps<Props, Param>
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Handle relative hrefs
|
|
45
|
+
*
|
|
46
|
+
* - If a link doesn't start with a slash OR it starts with './' it should replace the latest slug
|
|
47
|
+
* with the new path
|
|
48
|
+
* - If a link starts with a slash it shouldn't be relative
|
|
49
|
+
* - If a link starts with '../' it should move one segment up.
|
|
50
|
+
* - If a link starts with '../../' it should move two segments up, so this should be recursive
|
|
51
|
+
*/
|
|
52
|
+
function relativeUrl(href: string[], currentHref: string[]): string[] {
|
|
53
|
+
if (href[0].startsWith('http') || href[0].startsWith('/')) return href
|
|
54
|
+
|
|
55
|
+
if (href[0].startsWith('#')) return [...currentHref, href[0]]
|
|
56
|
+
|
|
57
|
+
if (href[0] === 'readme') return relativeUrl(['', ...href.slice(1)], currentHref)
|
|
58
|
+
|
|
59
|
+
if (href[0] === '..') {
|
|
60
|
+
return relativeUrl(href.slice(1), currentHref.slice(0, -1))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (href[0] === '.') {
|
|
64
|
+
return ['', ...currentHref.slice(0, -1), ...href.slice(1)]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return relativeUrl(['.', ...href], currentHref)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function RelativeLink(props: Omit<JSX.IntrinsicElements['a'], 'ref'>) {
|
|
71
|
+
const asPath = useRouter().asPath?.split('?')[0].split('#')[0]
|
|
72
|
+
const { href = '', children, ...otherProps } = props
|
|
73
|
+
|
|
74
|
+
let newUrl = href.replace('.mdx', '')
|
|
75
|
+
newUrl = newUrl.replace('.md', '')
|
|
76
|
+
newUrl = newUrl.replace('readme', '')
|
|
77
|
+
|
|
78
|
+
newUrl = relativeUrl(newUrl.split('/'), asPath.split('/').slice(1)).join('/')
|
|
79
|
+
|
|
80
|
+
if (newUrl.startsWith('/packages') || newUrl.startsWith('/examples')) {
|
|
81
|
+
newUrl = `https://github.com/ho-nl/m2-pwa/tree/master${newUrl}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const isExternal = newUrl.startsWith('http')
|
|
85
|
+
|
|
86
|
+
if (!newUrl.startsWith('/') && !isExternal) newUrl = `/${newUrl}`
|
|
87
|
+
if (newUrl.endsWith('/')) newUrl = newUrl.slice(0, -1)
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<PageLink href={newUrl} passHref>
|
|
91
|
+
<Link {...otherProps} target={isExternal ? '_blank' : undefined}>
|
|
92
|
+
{children}
|
|
93
|
+
</Link>
|
|
94
|
+
</PageLink>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const mdxComponents: React.ComponentProps<typeof MDXRemote>['components'] = {
|
|
99
|
+
h1: ({ ref, ...props }) => (
|
|
100
|
+
<Typography
|
|
101
|
+
component='h1'
|
|
102
|
+
variant='h1'
|
|
103
|
+
{...props}
|
|
104
|
+
sx={{ mt: '2em', mb: '1em', '&:first-of-type': { mt: '1em' } }}
|
|
105
|
+
/>
|
|
106
|
+
),
|
|
107
|
+
h2: ({ ref, ...props }) => (
|
|
108
|
+
<Typography
|
|
109
|
+
component='h2'
|
|
110
|
+
variant='h2'
|
|
111
|
+
{...props}
|
|
112
|
+
sx={{ mt: '2em', mb: '0.5em', borderBottom: (theme) => `1px solid ${theme.palette.divider}` }}
|
|
113
|
+
/>
|
|
114
|
+
),
|
|
115
|
+
h3: ({ ref, ...props }) => (
|
|
116
|
+
<Typography component='h3' variant='h3' {...props} sx={{ mt: '2em', mb: '0.5em' }} />
|
|
117
|
+
),
|
|
118
|
+
h4: ({ ref, ...props }) => <Typography component='h4' variant='h4' {...props} sx={{}} />,
|
|
119
|
+
h5: ({ ref, ...props }) => <Typography component='h5' variant='h5' {...props} sx={{}} />,
|
|
120
|
+
h6: ({ ref, ...props }) => <Typography component='h6' variant='h6' {...props} sx={{}} />,
|
|
121
|
+
p: ({ ref, ...props }) => (
|
|
122
|
+
<Typography variant='body1' {...props} sx={{ mt: '0.5em', mb: '1em' }} />
|
|
123
|
+
),
|
|
124
|
+
// img: ({ ref, src, ...props }) => {
|
|
125
|
+
// if (!src) return null
|
|
126
|
+
// return <Image layout={!props.width ? 'intrinsic' : 'responsive'} src={src} {...props} />
|
|
127
|
+
// },
|
|
128
|
+
hr: ({ ref, ...props }) => (
|
|
129
|
+
<Divider {...props} variant='middle' sx={(theme) => ({ my: theme.spacings.md })} />
|
|
130
|
+
),
|
|
131
|
+
blockquote: ({ ref, ...props }) => (
|
|
132
|
+
<Typography
|
|
133
|
+
variant='body1'
|
|
134
|
+
component='blockquote'
|
|
135
|
+
{...props}
|
|
136
|
+
sx={[
|
|
137
|
+
(theme) => ({
|
|
138
|
+
display: 'inline-block',
|
|
139
|
+
mt: '1em',
|
|
140
|
+
mb: '0.5em',
|
|
141
|
+
fontStyle: 'italic',
|
|
142
|
+
pl: '1em',
|
|
143
|
+
pr: '1em',
|
|
144
|
+
pt: '0.5em',
|
|
145
|
+
borderRadius: 2,
|
|
146
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.1),
|
|
147
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
148
|
+
boxShadow: 4,
|
|
149
|
+
'&:first-of-type': { mt: '2em' },
|
|
150
|
+
}),
|
|
151
|
+
]}
|
|
152
|
+
/>
|
|
153
|
+
),
|
|
154
|
+
pre: ({ ref, ...props }) => (
|
|
155
|
+
<Box
|
|
156
|
+
component='pre'
|
|
157
|
+
{...props}
|
|
158
|
+
sx={{
|
|
159
|
+
fontFamily: `Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace`,
|
|
160
|
+
borderRadius: 1.5,
|
|
161
|
+
maxWidth: (theme) => `calc(100vw - ${theme.page.horizontal} * 2)`,
|
|
162
|
+
|
|
163
|
+
// "&:not([class*='language-'])": {
|
|
164
|
+
// backgroundColor: (theme) => [alpha(theme.palette.text.primary, 0.08), '!important'],
|
|
165
|
+
// p: '1em',
|
|
166
|
+
// },
|
|
167
|
+
|
|
168
|
+
"&[class*='language-']": {
|
|
169
|
+
backgroundImage: 'linear-gradient(to top, #003c6780, #00264180 )',
|
|
170
|
+
},
|
|
171
|
+
'&.language-txt': {
|
|
172
|
+
background: 'none',
|
|
173
|
+
border: (theme) => `1px solid ${theme.palette.divider}`,
|
|
174
|
+
'& code': {
|
|
175
|
+
color: (theme) => [theme.palette.text.primary, '!important'],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
),
|
|
181
|
+
code: ({ ref, ...props }) => (
|
|
182
|
+
<Box
|
|
183
|
+
component='code'
|
|
184
|
+
{...props}
|
|
185
|
+
sx={{
|
|
186
|
+
fontSize: '0.85em',
|
|
187
|
+
"&:not([class*='language-'])": {
|
|
188
|
+
fontFamily: `Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace`,
|
|
189
|
+
borderRadius: 1.5,
|
|
190
|
+
pt: 0.1,
|
|
191
|
+
pb: 0.3,
|
|
192
|
+
px: 0.7,
|
|
193
|
+
backgroundColor: (theme) => [alpha(theme.palette.text.primary, 0.08), '!important'],
|
|
194
|
+
},
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
),
|
|
198
|
+
a: RelativeLink,
|
|
199
|
+
table: ({ ref, ...props }) => (
|
|
200
|
+
<TableContainer component={Paper} elevation={4} sx={{ mb: 5 }}>
|
|
201
|
+
<Table {...props} size='small' aria-label='a dense table' />
|
|
202
|
+
</TableContainer>
|
|
203
|
+
),
|
|
204
|
+
thead: ({ ref, ...props }) => <TableHead {...props} />,
|
|
205
|
+
tbody: ({ ref, ...props }) => <TableBody {...props} />,
|
|
206
|
+
tr: ({ ref, ...props }) => <TableRow {...props} />,
|
|
207
|
+
th: ({ ref, align, ...props }) => <TableCell {...props} />,
|
|
208
|
+
td: ({ ref, align, ...props }) => <TableCell {...props} />,
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function IndexPage(props: Props) {
|
|
212
|
+
const { source } = props
|
|
213
|
+
const { metaTitle, menu, metaDescription } = source.frontmatter as MatterFields
|
|
214
|
+
const prettyRoute = useRouter()
|
|
215
|
+
.asPath.split('?')[0]
|
|
216
|
+
.split('/')
|
|
217
|
+
.map((v) => v.replace(/-/g, ' ').replace(/^./, (x) => x.toUpperCase()))
|
|
218
|
+
.reverse()
|
|
219
|
+
.filter(Boolean)
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<>
|
|
223
|
+
<PageMeta
|
|
224
|
+
title={metaTitle ?? menu ?? prettyRoute.join(' - ')}
|
|
225
|
+
metaDescription={metaDescription}
|
|
226
|
+
/>
|
|
227
|
+
<Container
|
|
228
|
+
maxWidth='md'
|
|
229
|
+
sx={(theme) => ({
|
|
230
|
+
position: 'relative',
|
|
231
|
+
'& figure': {
|
|
232
|
+
display: 'block',
|
|
233
|
+
margin: '0 auto',
|
|
234
|
+
maxWidth: '100%',
|
|
235
|
+
mb: 8,
|
|
236
|
+
mt: 8,
|
|
237
|
+
aspectRatio: '16 / 9',
|
|
238
|
+
width: '100%',
|
|
239
|
+
},
|
|
240
|
+
'& img, & video': {
|
|
241
|
+
display: 'block',
|
|
242
|
+
margin: '0 auto',
|
|
243
|
+
maxWidth: '100%',
|
|
244
|
+
boxShadow: '0 0px 40px 0 rgba(0,0,0,0.15)',
|
|
245
|
+
},
|
|
246
|
+
'& strong': {
|
|
247
|
+
fontVariationSettings: "'wght' 600",
|
|
248
|
+
},
|
|
249
|
+
'& pre': {
|
|
250
|
+
borderRadius: 2,
|
|
251
|
+
mt: '1em !important',
|
|
252
|
+
mb: '1em !important',
|
|
253
|
+
},
|
|
254
|
+
'& figure > figcaption': {
|
|
255
|
+
paddingLeft: '1em',
|
|
256
|
+
marginTop: '1em',
|
|
257
|
+
typography: 'caption',
|
|
258
|
+
color: 'text.secondary',
|
|
259
|
+
},
|
|
260
|
+
'& > details': {
|
|
261
|
+
width: '100%',
|
|
262
|
+
mt: '2em',
|
|
263
|
+
mb: '0.5em',
|
|
264
|
+
p: '1em',
|
|
265
|
+
borderRadius: 2,
|
|
266
|
+
backgroundColor: alpha(theme.palette.primary.dark, 0.1),
|
|
267
|
+
border: `1px solid ${theme.palette.primary.dark}`,
|
|
268
|
+
boxShadow: 4,
|
|
269
|
+
a: {
|
|
270
|
+
color: theme.palette.primary.dark,
|
|
271
|
+
textDecorationColor: theme.palette.primary.dark,
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
'& > div > details': {
|
|
275
|
+
summary: {
|
|
276
|
+
mb: 1,
|
|
277
|
+
},
|
|
278
|
+
h3: {
|
|
279
|
+
...theme.typography.h3,
|
|
280
|
+
display: 'inline-block',
|
|
281
|
+
},
|
|
282
|
+
a: {
|
|
283
|
+
color: theme.palette.text.primary,
|
|
284
|
+
textDecorationColor: theme.palette.text.primary,
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
'& hr': {
|
|
288
|
+
m: 0,
|
|
289
|
+
mt: 5,
|
|
290
|
+
mb: 5,
|
|
291
|
+
},
|
|
292
|
+
'& figure > p': { display: 'none' },
|
|
293
|
+
|
|
294
|
+
'& .icon.icon-link': {
|
|
295
|
+
background: 'url(/link.svg) no-repeat',
|
|
296
|
+
backgroundSize: 'contain',
|
|
297
|
+
display: 'inline-block',
|
|
298
|
+
verticalAlign: 'middle',
|
|
299
|
+
fontSize: '0.8em',
|
|
300
|
+
mr: '0.2em',
|
|
301
|
+
width: '1.1em',
|
|
302
|
+
height: '1.2em',
|
|
303
|
+
ml: `calc(-0.2em - 1.2em)`,
|
|
304
|
+
opacity: 0.0,
|
|
305
|
+
},
|
|
306
|
+
'& .contains-task-list': {
|
|
307
|
+
padding: 0,
|
|
308
|
+
'& li': {
|
|
309
|
+
listStyle: 'none',
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
'& h2:last-of-type': {
|
|
313
|
+
pl: 3,
|
|
314
|
+
pr: 3,
|
|
315
|
+
pt: 2,
|
|
316
|
+
pb: 2,
|
|
317
|
+
background: alpha(theme.palette.divider, 0.05),
|
|
318
|
+
mb: 0,
|
|
319
|
+
mt: 8,
|
|
320
|
+
borderTopLeftRadius: 10,
|
|
321
|
+
borderTopRightRadius: 10,
|
|
322
|
+
border: 0,
|
|
323
|
+
},
|
|
324
|
+
'& ul:last-of-type': {
|
|
325
|
+
pl: 3,
|
|
326
|
+
pr: 3,
|
|
327
|
+
pt: 0,
|
|
328
|
+
pb: 3,
|
|
329
|
+
mt: 0,
|
|
330
|
+
background: alpha(theme.palette.divider, 0.05),
|
|
331
|
+
borderBottomLeftRadius: 10,
|
|
332
|
+
borderBottomRightRadius: 10,
|
|
333
|
+
'& li': {
|
|
334
|
+
listStyle: 'none',
|
|
335
|
+
'&:before': {
|
|
336
|
+
content: '"— "',
|
|
337
|
+
mr: 1,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
'& h1:hover .icon.icon-link, & h2:hover .icon.icon-link, & h3:hover .icon.icon-link, & h4:hover .icon.icon-link, & h5:hover .icon.icon-link, & h6:hover .icon.icon-link':
|
|
342
|
+
{ opacity: 0.5 },
|
|
343
|
+
})}
|
|
344
|
+
>
|
|
345
|
+
<MDXRemote {...source} components={mdxComponents} />
|
|
346
|
+
</Container>
|
|
347
|
+
</>
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const pageOptions: PageOptions<LayoutFullProps> = {
|
|
352
|
+
Layout: LayoutFull,
|
|
353
|
+
}
|
|
354
|
+
IndexPage.pageOptions = pageOptions
|
|
355
|
+
|
|
356
|
+
export default IndexPage
|
|
357
|
+
|
|
358
|
+
export const getStaticPaths: GetStaticPaths<{ url: string[] }> = async () => {
|
|
359
|
+
const paths = await getDirectoryPaths('content')
|
|
360
|
+
|
|
361
|
+
return {
|
|
362
|
+
fallback: 'blocking',
|
|
363
|
+
paths: paths.map((p) => ({ params: { url: p.split('/') } })),
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export const getStaticProps: GetStatic = async ({ params }) => {
|
|
368
|
+
const url = params?.url ?? []
|
|
369
|
+
const menuData = await getDirectoryTree('content')
|
|
370
|
+
if (!menuData) return { notFound: true }
|
|
371
|
+
|
|
372
|
+
const filePath = urlToPath(url, menuData)
|
|
373
|
+
if (!filePath) return { notFound: true }
|
|
374
|
+
|
|
375
|
+
const res = await getFileContents('content', filePath)
|
|
376
|
+
|
|
377
|
+
if (res === false) return { notFound: true }
|
|
378
|
+
|
|
379
|
+
// todo: https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins
|
|
380
|
+
// todo: https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins
|
|
381
|
+
const source = (await serialize(res, {
|
|
382
|
+
mdxOptions: {
|
|
383
|
+
format: 'detect',
|
|
384
|
+
remarkPlugins: [remarkGfm],
|
|
385
|
+
rehypePlugins: [rehypePrism, rehypeSlug, rehypeAutolinkHeadings],
|
|
386
|
+
},
|
|
387
|
+
parseFrontmatter: true,
|
|
388
|
+
})) as MDXSource
|
|
389
|
+
|
|
390
|
+
return { props: { menuData, source } }
|
|
391
|
+
}
|
package/pages/_app.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FramerNextPages } from '@graphcommerce/framer-next-pages'
|
|
2
|
+
// import { GoogleAnalyticsScript } from '@graphcommerce/googleanalytics'
|
|
3
|
+
// import { GoogleRecaptchaV3Script } from '@graphcommerce/googlerecaptcha'
|
|
4
|
+
// import { GoogleTagManagerScript } from '@graphcommerce/googletagmanager'
|
|
5
|
+
import { CssAndFramerMotionProvider, GlobalHead, PageLoadIndicator } from '@graphcommerce/next-ui'
|
|
6
|
+
import { CssBaseline, ThemeProvider } from '@mui/material'
|
|
7
|
+
import { AppProps } from 'next/app'
|
|
8
|
+
import { lightTheme } from '../components/theme'
|
|
9
|
+
import '../components/prism.css'
|
|
10
|
+
import '../components/rehype-prism-plus.css'
|
|
11
|
+
|
|
12
|
+
export default function ThemedApp(props: AppProps) {
|
|
13
|
+
return (
|
|
14
|
+
<CssAndFramerMotionProvider>
|
|
15
|
+
<ThemeProvider theme={lightTheme}>
|
|
16
|
+
{/* <GoogleAnalyticsScript /> */}
|
|
17
|
+
{/* <GoogleRecaptchaV3Script /> */}
|
|
18
|
+
{/* <GoogleTagManagerScript /> */}
|
|
19
|
+
<GlobalHead name='GraphCommerce Docs' />
|
|
20
|
+
<CssBaseline />
|
|
21
|
+
<PageLoadIndicator />
|
|
22
|
+
<FramerNextPages {...props} fallbackRoute='/[[...url]]' />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
</CssAndFramerMotionProvider>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// import { GoogleTagManagerNoScript } from '@graphcommerce/googletagmanager'
|
|
2
|
+
import { EmotionCacheProps, withEmotionCache } from '@graphcommerce/next-ui'
|
|
3
|
+
import NextDocument, { Html, Head, Main, NextScript } from 'next/document'
|
|
4
|
+
|
|
5
|
+
class Document extends NextDocument<EmotionCacheProps> {
|
|
6
|
+
render() {
|
|
7
|
+
return (
|
|
8
|
+
<Html>
|
|
9
|
+
<Head>
|
|
10
|
+
{/* Inject MUI styles first to match with the prepend: true configuration. */}
|
|
11
|
+
{this.props.emotionStyleTags}
|
|
12
|
+
</Head>
|
|
13
|
+
<body>
|
|
14
|
+
<Main />
|
|
15
|
+
<NextScript />
|
|
16
|
+
</body>
|
|
17
|
+
</Html>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default withEmotionCache(Document)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PageOptions } from '@graphcommerce/framer-next-pages'
|
|
2
|
+
import { LayoutOverlay, LayoutOverlayProps, PageMeta } from '@graphcommerce/next-ui'
|
|
3
|
+
import { GetStaticPaths, GetStaticProps } from 'next'
|
|
4
|
+
import { useRouter } from 'next/router'
|
|
5
|
+
import { Search } from '../../components/Search'
|
|
6
|
+
import SidebarMenu from '../../components/SidebarMenu'
|
|
7
|
+
import {
|
|
8
|
+
FileNode,
|
|
9
|
+
getDirectoryPaths,
|
|
10
|
+
getDirectoryTree,
|
|
11
|
+
getFileContents,
|
|
12
|
+
urlToPath,
|
|
13
|
+
} from '../../lib/files'
|
|
14
|
+
|
|
15
|
+
type Props = { menuData: FileNode } & LayoutOverlayProps
|
|
16
|
+
type Param = { url: string[] }
|
|
17
|
+
|
|
18
|
+
export default function MenuPage(props: Props) {
|
|
19
|
+
const { menuData } = props
|
|
20
|
+
const url = (useRouter().query.url as Param['url'] | undefined)?.join('/') ?? ''
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<PageMeta title='GraphCommerce Documentation' />
|
|
25
|
+
<Search />
|
|
26
|
+
<SidebarMenu {...menuData} selected={`/${url}`} />
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const pageOptions: PageOptions<LayoutOverlayProps> = {
|
|
32
|
+
Layout: (props: LayoutOverlayProps) => (
|
|
33
|
+
<LayoutOverlay
|
|
34
|
+
{...props}
|
|
35
|
+
variantSm='bottom'
|
|
36
|
+
variantMd='left'
|
|
37
|
+
sizeMd='floating'
|
|
38
|
+
sizeSm='floating'
|
|
39
|
+
justifySm='start'
|
|
40
|
+
justifyMd='start'
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
overlayGroup: 'menu',
|
|
44
|
+
}
|
|
45
|
+
MenuPage.pageOptions = pageOptions
|
|
46
|
+
|
|
47
|
+
export const getStaticPaths: GetStaticPaths<{ url: string[] }> = async () => {
|
|
48
|
+
const paths = await getDirectoryPaths('content')
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
fallback: 'blocking',
|
|
52
|
+
paths: paths.map((p) => ({ params: { url: p.split('/') } })),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const getStaticProps: GetStaticProps<Props, Param> = async ({ params }) => {
|
|
57
|
+
const url = params?.url ?? []
|
|
58
|
+
const menuData = await getDirectoryTree('content')
|
|
59
|
+
if (!menuData) return { notFound: true }
|
|
60
|
+
|
|
61
|
+
const filePath = urlToPath(url, menuData)
|
|
62
|
+
if (!filePath) return { notFound: true }
|
|
63
|
+
|
|
64
|
+
const res = await getFileContents('content', filePath)
|
|
65
|
+
|
|
66
|
+
if (res === false) return { notFound: true }
|
|
67
|
+
|
|
68
|
+
return { props: { menuData } }
|
|
69
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>favicon</title>
|
|
4
|
+
<g id="favicon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
+
<g id="Path" transform="translate(17.000000, 10.000000)">
|
|
6
|
+
<polygon fill="#000000" fill-rule="nonzero" opacity="0.200000003" points="42.81 50 9.46 69.47 9.46 69.47 9.46 69.47 9.46 69.48 9.46 69.48 42.81 88.95 76.16 69.47"></polygon>
|
|
7
|
+
<polygon fill="#000000" fill-rule="nonzero" opacity="0.400000006" points="42.81 31.55 9.46 51.02 9.46 51.02 9.46 51.02 9.46 51.03 9.46 51.03 42.81 70.5 76.16 51.02"></polygon>
|
|
8
|
+
<polygon fill="#000000" fill-rule="nonzero" points="42.81 11.05 9.46 30.52 9.46 30.52 9.46 30.52 9.46 30.53 9.46 30.53 42.81 50 76.16 30.52"></polygon>
|
|
9
|
+
<polygon stroke="#000000" stroke-width="5" points="0 25 0 75 42.81 100 85.62 75 85.62 25 42.81 0"></polygon>
|
|
10
|
+
</g>
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|
package/public/link.svg
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
3
|
+
<path d="M15.387 4.33c-2.1 0-3.6 1.9-5.1 3.3.2 0 .5-.1.8-.1.5 0 1 .1 1.5.3.8-.8 1.6-1.7 2.8-1.7.6 0 1.3.3 1.8.7 1 1 1 2.6 0 3.6l-2.6 2.6c-.4.4-1.2.7-1.8.7-1.4 0-2.1-.9-2.6-2l-1.3 1.3c.8 1.5 2 2.6 3.8 2.6 1.2 0 2.3-.5 3-1.3l2.6-2.6c.9-.9 1.5-2 1.5-3.3-.2-2.2-2.2-4.1-4.4-4.1zm-4.3 12.1l-.9.9c-.4.4-1.2.7-1.8.7-.6 0-1.3-.3-1.8-.7-1-1-1-2.7 0-3.6l2.6-2.6c.4-.4 1.2-.7 1.8-.7 1.4 0 2.1 1 2.6 2l1.3-1.3c-.8-1.5-2-2.6-3.8-2.6-1.2 0-2.3.5-3 1.3l-2.6 2.6c-1.7 1.7-1.7 4.4 0 6 1.6 1.6 4.4 1.7 5.9 0l1.9-1.9c-.3.1-.6.1-.9.1-.5 0-.9 0-1.3-.2z"/>
|
|
4
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "GraphCommerce",
|
|
3
|
+
"short_name": "GraphCommerce",
|
|
4
|
+
"display": "standalone",
|
|
5
|
+
"theme_color": "#000000",
|
|
6
|
+
"background_color": "#FFFFFF",
|
|
7
|
+
"start_url": "/",
|
|
8
|
+
"icons": [
|
|
9
|
+
{
|
|
10
|
+
"src": "/manifest/favicon-192.png",
|
|
11
|
+
"sizes": "192x192",
|
|
12
|
+
"type": "image/png"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"src": "/manifest/favicon-512.png",
|
|
16
|
+
"sizes": "512x512",
|
|
17
|
+
"type": "image/png"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|