-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
82 lines (78 loc) · 2.24 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const path = require('path');
const UnoCSS = require('@unocss/webpack').default;
// TODO:
// ref: https://github.com/spencerwooo/spencerwoo.com/blob/main/next.config.js
// - headers, security options, og:image, etc.
// - maybe: og in frontmatter, investigate nextra source code.
/**
* @type {import('next').NextConfig}
**/
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
webpack(config, context) {
config.plugins.push(UnoCSS());
config.optimization.realContentHash = true;
config.cache = false; // always turn off the cache for UnoCSS HMR
return config;
},
sassOptions: {
includePaths: [path.join(__dirname, './src/styles')]
},
async redirects() {
const redirects = [
// backwards compatibility
{
source: '/p/:slug',
destination: '/posts/:slug',
permanent: true
}
];
// use private drafts in local development
if (process.env.NODE_ENV == 'development') {
redirects.push({
source: '/posts/:slug',
destination: '/drafts/:slug',
permanent: true
});
} else {
const draftsRouter = [
{
source: '/drafts',
destination: '/404',
permanent: true
},
{
source: '/drafts/:slug',
destination: '/404',
permanent: true
}
];
redirects.push(...draftsRouter);
}
return redirects;
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
pathname: '/u/**'
},
{
protocol: 'https',
hostname: 'docs.unrealengine.com',
pathname: '/**/*'
}
]
}
};
const withNextra = require('nextra')({
theme: './src/layouts',
themeConfig: './theme.config.tsx',
latex: true,
staticImage: true,
defaultShowCopyCode: true,
readingTime: true
});
module.exports = withNextra(nextConfig);