mirror of
https://github.com/vercel/ai-elements.git
synced 2026-09-14 19:48:26 +08:00
cf793dd446
* Remove microfrontends * Remove /elements subpath, update URL * Fix local paths * Remove custom AI SDK navbar * Update global.css * Restore docs in path * Restore Geistdocs homepage * Split up docs, components and examples * New routes for components and examples * IA fixes * Update hero, start adding components to homepage * Experimenting with hero * Update pnpm-lock.yaml * Add new docs * Update geistdocs.tsx * Update examples, add new IDE example * Create source-code.tsx * Cleanup ide.mdx * Cleanup examples * Update homepage content * Misc fixes * Update elements-installer.tsx * Update meta.json * Deprecate Loader component for shadcn/ui Spinner * Add changeset files * Update homepage and templates * Update code-block.tsx * Misc fixes * Update callout.tsx * Remove hero badge * Resolves #328 * Build fixes * Update README.md
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { createI18nMiddleware } from "fumadocs-core/i18n/middleware";
|
|
import { isMarkdownPreferred, rewritePath } from "fumadocs-core/negotiation";
|
|
import {
|
|
type NextFetchEvent,
|
|
type NextRequest,
|
|
NextResponse,
|
|
} from "next/server";
|
|
import { i18n } from "@/lib/geistdocs/i18n";
|
|
|
|
const { rewrite: rewriteLLM } = rewritePath("/*path", "/en/llms.mdx/*path");
|
|
|
|
const internationalizer = createI18nMiddleware(i18n);
|
|
|
|
const proxy = (request: NextRequest, context: NextFetchEvent) => {
|
|
console.log("[Proxy] Request pathname:", request.nextUrl.pathname);
|
|
|
|
// First, handle Markdown preference rewrites
|
|
if (isMarkdownPreferred(request)) {
|
|
const result = rewriteLLM(request.nextUrl.pathname);
|
|
if (result) {
|
|
return NextResponse.rewrite(new URL(result, request.nextUrl));
|
|
}
|
|
}
|
|
|
|
// Fallback to i18n middleware
|
|
return internationalizer(request, context);
|
|
};
|
|
|
|
export const config = {
|
|
// Matcher ignoring `/_next/`, `/api/`, static assets, favicon, etc.
|
|
// Explicitly include root path and all other paths
|
|
matcher: ["/", "/((?!api|_next/static|_next/image|favicon.ico).*)"],
|
|
};
|
|
|
|
export default proxy;
|