forked from graphprotocol/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
90 lines (86 loc) · 2.34 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
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
import nextra from 'nextra'
const env = {
ENVIRONMENT: process.env.ENVIRONMENT,
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.NODE_ENV === 'production'
? process.env.ENVIRONMENT === 'production'
? 'cfeac8baf33c9b4d255f28d57f3c9148' // production
: 'e57a9892339b2acfd02943c86b746d32' // staging
: '', // local dev (no tracking)
GOOGLE_ANALYTICS_MEASUREMENT_ID: process.env.NODE_ENV === 'production' ? 'G-5MK48LFNKY' : '',
}
const withNextra = nextra({
theme: '@graphprotocol/nextra-theme',
staticImage: true,
flexsearch: false,
codeHighlight: false,
defaultShowCopyCode: false,
readingTime: true,
transform(result, { route }) {
if (route && !result.includes('getStaticProps')) {
const banner = `
import { getPageMap } from '@/src/getPageMap'
export const getStaticProps = async context => ({
props: {
__nextra_pageMap: await getPageMap('${route.split('/')[1]}')
}
})`
result += banner
}
return result
},
})
/**
* @type {import('next').NextConfig}
*/
export default withNextra({
env,
output: 'export',
distDir: process.env.NODE_ENV === 'production' ? '../out/docs' : undefined,
experimental: {
// Fix scroll restoration (see https://github.com/vercel/next.js/issues/37893#issuecomment-1221335543)
scrollRestoration: true,
},
pageExtensions: ['tsx'],
reactStrictMode: true,
basePath: env.BASE_PATH,
trailingSlash: true,
redirects: () => [
{
source: '/',
destination: '/en/',
permanent: true,
},
{
source: '/en/arbitrum-faq/',
destination: '/en/arbitrum/arbitrum-faq/',
permanent: true,
},
{
source: '/en/querying/graph-client/',
destination: '/en/querying/graph-client/README/',
permanent: false,
},
{
source: '/en/developing/graph-ts/',
destination: '/en/developing/graph-ts/README/',
permanent: false,
},
{
source: '/en/developer/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
{
source: '/en/developing/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
],
images: {
unoptimized: true,
},
})