mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 04:19:26 +00:00
docs: support markdown response for AI (#5105)
This commit is contained in:
20
docs/middleware.ts
Normal file
20
docs/middleware.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isMarkdownPreferred, rewritePath } from "fumadocs-core/negotiation";
|
||||
|
||||
const { rewrite: rewriteLLM } = rewritePath("/docs/*path", "/llms.txt/*path");
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
if (isMarkdownPreferred(request)) {
|
||||
const result = rewriteLLM(request.nextUrl.pathname);
|
||||
|
||||
if (result) {
|
||||
return NextResponse.rewrite(new URL(result, request.nextUrl));
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/docs/:path*",
|
||||
};
|
||||
Reference in New Issue
Block a user