-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathnext.config.js
More file actions
151 lines (143 loc) · 3.99 KB
/
next.config.js
File metadata and controls
151 lines (143 loc) · 3.99 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
// @ts-check
import nextra from 'nextra'
import rehypeMdxCodeProps from 'rehype-mdx-code-props'
import { defaultLocale, translate } from '@edgeandnode/gds'
import { translations } from './dist/i18n.js'
import rehypeUnwrapImages from './dist/mdxPlugins/rehypeUnwrapImages.js'
import remarkCallouts from './dist/mdxPlugins/remarkCallouts.js'
import remarkTransformRemoteDocs from './dist/mdxPlugins/remarkTransformRemoteDocs.js'
const env = {
ENVIRONMENT: process.env.ENVIRONMENT,
ORIGIN: process.env.ORIGIN,
BASE_PATH: process.env.BASE_PATH,
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: './src/layout/Layout.tsx',
search: false,
codeHighlight: false,
defaultShowCopyCode: false,
readingTime: true,
transformPageMap(pageMap) {
const route = pageMap[0] && 'route' in pageMap[0] ? pageMap[0].route : undefined
const locale = typeof route === 'string' ? route.slice(1, 3) : defaultLocale
const t = (/** @type {string} */ key) =>
translate(
translations,
/** @type {import('@edgeandnode/gds').Locale} */
(locale),
/** @type {any} */
(key),
)
// TODO: Move back to `src/pages/en/_meta.js` and add `src/pages/en/_meta-titles.json` for the translations
const metaFile = {
index: t('index.title'),
about: '',
'supported-networks': '',
contracts: '',
'---1': {
type: 'separator',
},
subgraphs: {
type: 'children',
title: t('global.navigation.subgraphs'),
},
'---2': {
type: 'separator',
},
substreams: {
type: 'children',
title: t('global.navigation.substreams'),
},
'---3': {
type: 'separator',
},
'token-api': {
type: 'children',
title: t('global.navigation.tokenApi'),
},
'---4': {
type: 'separator',
},
hypergraph: {
type: 'children',
title: t('global.navigation.hypergraph'),
},
'---5': {
type: 'separator',
},
'ai-suite': {
type: 'children',
title: t('global.navigation.ai-suite'),
},
'---6': {
type: 'separator',
},
indexing: {
type: 'children',
title: t('global.navigation.indexing'),
},
'---7': {
type: 'separator',
},
resources: {
type: 'children',
title: t('global.navigation.resources'),
},
archived: {
type: 'children',
title: t('global.navigation.archived'),
},
}
return [
{ data: metaFile },
{
route: `/${locale}`,
name: 'index',
frontMatter: {},
},
...pageMap,
]
},
mdxOptions: {
remarkPlugins: [remarkCallouts, remarkTransformRemoteDocs],
rehypePlugins: [rehypeUnwrapImages, rehypeMdxCodeProps],
},
})
/** @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: async () => [
{
source: '/',
destination: '/en/',
permanent: true,
},
// If we ever change `output` to not be `export`, we should move all the redirects from `nginx.conf` here
],
images: {
unoptimized: true,
},
i18n: {
defaultLocale,
locales: Object.keys(translations),
},
})