-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
56 lines (53 loc) · 1.36 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
const redirects = require('./redirects.json')
const encodeRedirectURL = (text) => {
const regHttp = /^(https?)/
if (regHttp.test(text)) {
// 外部リンク
const splitIndex = text.indexOf(':') + 1
const http = text.substring(0, splitIndex)
const url = text.substring(splitIndex)
return http + encodeRedirectURL(url)
} else {
const separators = /([/ /? = &])/g
return text
.split(separators)
.map((e) => {
if (separators.test(e)) return e
else return encodeURIComponent(e)
})
.join('')
}
}
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
remotePatterns: [
{
hostname: 'images.ctfassets.net',
protocol: 'https',
pathname: `/${process.env.CONTENTFUL_SPACE_ID}/**`,
},
],
},
rewrites: async () => {
return [
{
source: '/researches/:slug/assets/:name',
destination: '/api/asset-paper/:slug',
},
]
},
redirects: async () => {
return [...redirects].filter(e=>e.source!==e.destination).map((item) => ({
source: encodeRedirectURL(item.source),
destination: encodeRedirectURL(item.destination),
permanent: item.permanent,
}))
},
experimental: {
scrollRestoration: true,
largePageDataBytes: 1024 * 1000, //1MB
},
}
module.exports = nextConfig