forked from graphprotocol/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
64 lines (61 loc) · 1.68 KB
/
next.config.js
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
import nextra from 'nextra'
const env = {
BASE_PATH: process.env.NODE_ENV === 'production' ? '/docs' : '',
ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
MIXPANEL_TOKEN:
process.env.ENVIRONMENT === 'production' ? 'cfeac8baf33c9b4d255f28d57f3c9148' : 'e57a9892339b2acfd02943c86b746d32',
}
const withNextra = nextra({
theme: '@graphprotocol/nextra-theme',
staticImage: true,
flexsearch: false,
codeHighlight: false,
defaultShowCopyCode: false,
transformPageOpts(pageOpts) {
if (pageOpts.filePath === 'pages/_app.mdx') {
pageOpts.pageMap = pageOpts.pageMap
// remove redundant dynamic page folder
.filter((pageItem) => pageItem.name !== '[locale]')
.map((pageItem) => {
if (pageItem.kind === 'Folder' && pageItem.name.length === 2) {
// add missing dynamic index page
return {
...pageItem,
children: [{ kind: 'MdxPage', name: 'index', route: pageItem.route }, ...pageItem.children],
}
}
return pageItem
})
}
return pageOpts
},
})
export default withNextra({
experimental: {
// Fix scroll restoration (see https://github.com/vercel/next.js/issues/37893#issuecomment-1221335543)
scrollRestoration: true,
},
env,
pageExtensions: ['tsx'],
reactStrictMode: true,
basePath: env.BASE_PATH,
trailingSlash: true,
redirects: () => [
{
source: '/',
destination: '/en/',
permanent: false,
},
],
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
})
return config
},
images: {
unoptimized: true,
},
})