/
[[...slug]].jsx
51 lines (45 loc) · 1.36 KB
/
[[...slug]].jsx
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
import Head from 'next/head'
import { withRouter } from 'next/router'
import { pageProps, staticPaths } from '@zentered/next-product-docs/serialize'
import { Documentation } from '@zentered/next-product-docs'
import Sidebar from '../../components/Sidebar'
import Toc from '../../components/Toc'
import theme from '../../utils/vsDark.js'
const docOptions = {
docsFolder: 'docs',
trailingSlash: true
}
function DocumentationPage({ title, source, sidebarRoutes, tocHeadings }) {
if (source === null) {
source = ''
}
return (
<>
<Head>
<title>{`${title}`}</title>
<meta name="description" />
<link rel="icon" href="/favicon.ico" />
</Head>
<div className="lg:container">
<div className="md:flex max-w-7xl mx-auto">
<Sidebar routes={sidebarRoutes} />
<main className="md:flex-1 ml-4 xl:ml-8 pr-4 sm:pr-0">
<Documentation source={source} theme={theme} />
</main>
<Toc contents={tocHeadings} />
</div>
</div>
</>
)
}
export async function getStaticPaths() {
console.log('load paths')
const paths = await staticPaths(docOptions)
return { paths, fallback: false }
}
export async function getStaticProps(ctx) {
console.log('load page')
const props = await pageProps(ctx, docOptions)
return { props }
}
export default withRouter(DocumentationPage)