-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
89 lines (82 loc) · 2.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
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
83
84
85
86
87
88
89
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
const env = await import("./src/env.js");
import createNextIntlPlugin from "next-intl/plugin";
import { withAxiom } from "next-axiom";
import createMDX from "@next/mdx";
import createBundleAnalyzer from "@next/bundle-analyzer";
/** @type {import("next").NextConfig} */
const config = {
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
headers: async () => {
/** @type {Awaited<ReturnType<NonNullable<import("next").NextConfig["headers"]>>>} */
const headers = [
{
// Cache sitemap
source: "/sitemap.xml",
headers: [
{
key: "Cache-Control",
value:
"public, max-age=60, s-maxage=600, stale-while-revalidate=14400, stale-if-error=14400",
},
],
},
];
// disable indexing on non-production environments
if (env.env.VERCEL_ENV !== "production") {
headers.push({
source: "/:path*",
headers: [
{
key: "X-Robots-Tag",
value: "noindex, nofollow",
},
],
});
}
return headers;
},
redirects: async () => {
return [
{
// Redirects from /regions/:region to /region/:region
source: "/regions/:region",
destination: "/region/:region",
permanent: true,
},
{
// Redirects from /authors/:authorSlug to /author/:authorSlug
source: "/authors/:authorSlug",
destination: "/author/:authorSlug",
permanent: true,
},
{
// Redirects from /centuries/:century to /century/:century
source: "/centuries/:century",
destination: "/century/:century",
permanent: true,
},
{
// Redirects from /genres/:genreSlug to /genre/:genreSlug
source: "/genres/:genreSlug",
destination: "/genre/:genreSlug",
permanent: true,
},
];
},
};
const withNextIntl = createNextIntlPlugin();
const withMDX = createMDX({
options: {
remarkPlugins: [],
rehypePlugins: [],
},
});
const withBundleAnalyzer = createBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
});
const plugins = [withBundleAnalyzer, withMDX, withNextIntl, withAxiom];
export default plugins.reduce((acc, plugin) => plugin(acc), config);