docs: serve markdown to agents (#13915)
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import type { NextRequest } from "next/server"
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
return NextResponse.rewrite(
|
||||
new URL(
|
||||
`${request.nextUrl.basePath}/md-content${request.nextUrl.pathname.replace("/index.html.md", "")}`,
|
||||
request.url
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/:path*/index.html.md",
|
||||
}
|
||||
@@ -152,6 +152,38 @@ const nextConfig = {
|
||||
permanent: true,
|
||||
},
|
||||
],
|
||||
rewrites: async () => {
|
||||
return {
|
||||
beforeFiles: [
|
||||
{
|
||||
source: "/:path*/index.html.md",
|
||||
destination: "/md-content/:path*",
|
||||
},
|
||||
{
|
||||
source: "/:path*",
|
||||
has: [
|
||||
{
|
||||
type: "header",
|
||||
key: "accept",
|
||||
value: "text/markdown",
|
||||
},
|
||||
],
|
||||
destination: "/md-content/:path*",
|
||||
},
|
||||
{
|
||||
source: "/:path*",
|
||||
destination: "/md-content/:path*",
|
||||
has: [
|
||||
{
|
||||
type: "header",
|
||||
key: "accept",
|
||||
value: "text/plain",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const withBundleAnalyzer = bundleAnalyzer({
|
||||
|
||||
Reference in New Issue
Block a user