forked from invertase/docs.page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
63 lines (59 loc) · 1.46 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
const domains = require('./domains.json');
// const domains = domainList.filter(([domain,repository]) => domain !== 'melos.invertase.dev')
module.exports = {
experimental: { esmExternals: true },
async redirects() {
return [
{
source: '/',
destination: '/homepage',
permanent: true,
},
];
},
async rewrites() {
const beforeFiles = domains.map(([domain, repository]) => {
const [organization, repo] = repository.split('/');
return {
source: '/',
has: [
{
type: 'host',
value: domain,
},
],
destination: `/${organization}/${repo}`,
};
});
const afterFiles = [];
domains.forEach(([domain, repository]) => {
const [organization, repo] = repository.split('/');
// beforeFiles sends the request here to afterFiles, so we need to
// make sure we don't double prefix the org/repo to the request.
afterFiles.push({
source: `/${organization}/${repo}`,
has: [
{
type: 'host',
value: domain,
},
],
destination: `/${organization}/${repo}`,
});
afterFiles.push({
source: `/:path*`,
has: [
{
type: 'host',
value: domain,
},
],
destination: `/${organization}/${repo}/:path*`,
});
});
return {
beforeFiles,
afterFiles,
};
},
};