-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
63 lines (59 loc) · 1.49 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
/** @type {import('next').NextConfig} */
/* eslint-disable @typescript-eslint/no-var-requires */
const { withPlaiceholder } = require('@plaiceholder/next')
const prismic = require('@prismicio/client')
const fetch = require('node-fetch')
const nextConfig = async () => {
let locales = ['en-us']
try {
const client = prismic.createClient(process.env.NEXT_PUBLIC_API_ENDPOINT, {
fetch
})
const repository = await client.getRepository()
locales = repository.languages.map(lang => lang.id)
} catch (e) {
console.log(e)
}
return withPlaiceholder({
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'images.prismic.io'
}
]
},
rewrites: async () => [
{
source: '/sitemap.xml',
destination: '/api/sitemap'
},
{
source: '/rss.xml',
destination: '/api/rss/:locale',
has: [{ type: 'query', key: 'locale' }]
},
{
source: '/rss.xml',
destination: `/api/rss/${process.env.DEFAULT_LOCALE || locales[0]}`
}
],
redirects: async () => {
return [
{
source: '/admin',
destination: `https://${prismic.getRepositoryName(
process.env.NEXT_PUBLIC_API_ENDPOINT
)}.prismic.io`,
permanent: true
}
]
},
i18n: {
locales,
defaultLocale: process.env.DEFAULT_LOCALE || locales[0]
}
})
}
module.exports = nextConfig