-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnext.config.ts
More file actions
126 lines (112 loc) · 3.32 KB
/
Copy pathnext.config.ts
File metadata and controls
126 lines (112 loc) · 3.32 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import fs from "fs";
import path from "path";
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import matter from "gray-matter";
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
// Generate redirects from markdown files (trailing slash cleanup only)
function generateBlogRedirects() {
const redirects: Array<{
source: string;
destination: string;
permanent: boolean;
}> = [];
const blogDir = path.join(process.cwd(), "src/content/blog");
if (!fs.existsSync(blogDir)) {
return redirects;
}
const files = fs.readdirSync(blogDir);
for (const filename of files) {
if (!filename.endsWith(".md")) continue;
const filePath = path.join(blogDir, filename);
const fileContent = fs.readFileSync(filePath, "utf8");
const { data } = matter(fileContent);
if (!data.permalink) continue;
const slug = data.permalink.replace(/^\//, "").replace(/\/$/, "");
const target = `/${slug}`;
// Only redirect if original URL has trailing slash
if (data.permalink.endsWith("/")) {
redirects.push({
source: data.permalink,
destination: target,
permanent: true,
});
}
}
return redirects;
}
const nextConfig: NextConfig = {
env: {
BASE_URL: "https://nouns.build",
},
images: {
// Proposal banners / Zora media are immutable IPFS content — cache long.
minimumCacheTTL: 2592000,
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
typescript: {
ignoreBuildErrors: false,
},
poweredByHeader: false,
reactCompiler: true,
experimental: {
// Increase body size limit for video thumbnail uploads (default is ~4-5MB)
serverActions: {
bodySizeLimit: "10mb",
},
// Persist Turbopack compile artifacts across dev restarts (Next.js 16 beta).
turbopackFileSystemCacheForDev: true,
},
async redirects() {
const blogRedirects = generateBlogRedirects();
return [
// Legacy proposal routes (before multi-chain support)
// Redirect /proposals/119 -> /proposals/base/119
// Permanent (301) redirect for proper SEO handling
{
source: "/proposals/:id(\\d+)",
destination: "/proposals/base/:id",
permanent: true,
},
// DAO URL pattern changes
{
source: "/dao/proposal/:id",
destination: "/proposals/:id",
permanent: true,
},
{
source: "/dao/proposals",
destination: "/proposals",
permanent: true,
},
{
source: "/dao/auction/:id",
destination: "/auctions",
permanent: true,
},
// /newhome was the homepage rebuild's staging route before it took over
// `/`. It carried no SEO weight (it shipped noindex), but the link was
// handed around during review, so it lands on the real homepage instead
// of a 404. Both locales, since localePrefix is "as-needed" and only
// pt-BR carries a prefix.
{
source: "/newhome",
destination: "/",
permanent: true,
},
{
source: "/pt-br/newhome",
destination: "/pt-br",
permanent: true,
},
// Blog post trailing slash cleanup (generated from markdown files)
...blogRedirects,
];
},
};
export default withNextIntl(nextConfig);