-
Notifications
You must be signed in to change notification settings - Fork 37
/
next.config.js
53 lines (51 loc) · 1.57 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
const config = require('./docs.config.js');
const {withContentlayer} = require('next-contentlayer');
const {updatedRedirectsData} = require('./src/data/redirects.ts');
const {generateRssFeed} = require('./dev/rss');
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// in prod, we serve the docs from sourcegraph.com/docs, and this requires special config on the GFE side
// in preview/development, this is not necessary.
//
// VERCEL_ENV is a system env var set by Vercel
// https://vercel.com/docs/projects/environment-variables/system-environment-variables
// basePath: process.env.VERCEL_ENV === 'production' ? '/docs' : '',
basePath: '/docs',
async redirects() {
return [
...updatedRedirectsData,
{
source: `/v/${config.DOCS_LATEST_VERSION}/:slug*`,
destination: `https://sourcegraph.com/docs/:slug*`,
permanent: false
},
{
source: `/@${config.DOCS_LATEST_VERSION}/:slug*`,
destination: `https://sourcegraph.com/docs/:slug*`,
permanent: false
},
{
source: '/v/:version(\\d+\\.\\d+)/:slug*',
destination: 'https://:version.sourcegraph.com/:slug*',
permanent: true
},
{
source: '/@:version(\\d+\\.\\d+)/:slug*',
destination: 'https://:version.sourcegraph.com/:slug*',
permanent: true
},
{
source: '/changelog.rss',
destination: '/technical-changelog.rss',
permanent: true
}
];
}
};
module.exports = async () => {
// placing this here so its part of nextjs's build process
await generateRssFeed();
return withContentlayer(nextConfig);
};