-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathnext.config.ts
More file actions
107 lines (94 loc) · 2.82 KB
/
Copy pathnext.config.ts
File metadata and controls
107 lines (94 loc) · 2.82 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
import { createMDX } from "fumadocs-mdx/next";
import type { NextConfig } from "next";
const withMDX = createMDX();
const publishedSchemaPaths = [
"/schemas/1.0.0/plugin.schema.json",
"/schemas/1.0.0/mcp.schema.json",
] as const;
const immutableSchemaHeaders = [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
];
const redirectHosts = [
"open-plugins.com",
"www.open-plugins.com",
"agent-plugins.io",
"www.agent-plugins.io",
"www.agent-plugins.org",
] as const;
const escapeRegex = (value: string) =>
value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
// `has.value` is a regular expression. Group the complete alternation because
// Next.js anchors the value when it compiles the host condition.
const redirectHostPattern = `(?:${redirectHosts.map(escapeRegex).join("|")})`;
const legacyPageMapping = [
["/agent-builders", "/client-implementers"],
[
"/agent-builders/components/mcp-servers",
"/client-implementers/mcp-runtime",
],
["/agent-builders/components/skills", "/plugin-authors/skills"],
["/plugin-builders", "/plugin-authors"],
["/plugin-builders/installation", "/plugin-authors"],
["/plugin-builders/specification", "/specification"],
["/supported-agents", "/client-implementers"],
] as const;
const legacyPageRedirects = legacyPageMapping.flatMap(([source, destination]) => [
{ source, destination, permanent: true as const },
{
source: `${source}.:extension(md|mdx)`,
destination: `${destination}.:extension`,
permanent: true as const,
},
]);
const config: NextConfig = {
experimental: {
turbopackFileSystemCacheForDev: true,
},
images: {
formats: ["image/avif", "image/webp"],
},
async headers() {
return publishedSchemaPaths.map((source) => ({
source,
headers: immutableSchemaHeaders,
}));
},
async redirects() {
return [
{
source: "/:path*",
has: [{ type: "host", value: redirectHostPattern }],
destination: "https://agent-plugins.org/:path*",
permanent: true,
},
...legacyPageRedirects,
{
source:
"/agent-builders/components/:component(agents|hooks|lsp-servers|rules)",
destination: "/specification#why-only-agent-skills-and-mcp-in-v1",
permanent: false,
},
{
source:
"/agent-builders/components/:component(agents|hooks|lsp-servers|rules).:extension(md|mdx)",
destination:
"/specification.:extension#why-only-agent-skills-and-mcp-in-v1",
permanent: false,
},
{
source: "/plugin-builders/marketplace",
destination: "/",
permanent: true,
},
{
source: "/plugin-builders/marketplace.:extension(md|mdx)",
destination: "/docs.:extension",
permanent: true,
},
];
},
};
export default withMDX(config);