Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 0 additions & 168 deletions apps/docs/lib/ai-agent-detection.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/docs/lib/geistdocs/md-tracking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { siteId } from "@/geistdocs";
import type { DetectionMethod } from "@/lib/ai-agent-detection";
import type { DetectionMethod } from "@vercel/agent-readability";

const PLATFORM_URL = "https://geistdocs.com/md-tracking";

Expand Down
3 changes: 2 additions & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check failure on line 1 in apps/docs/package.json

View workflow job for this annotation

GitHub Actions / Biome

format

File content differs from formatting output
"name": "docs",
"version": "0.0.0",
"private": true,
Expand All @@ -15,6 +15,7 @@
"@orama/tokenizers": "^3.1.16",
"@streamdown/cjk": "^1.0.1",
"@streamdown/code": "^1.0.1",
"@vercel/agent-readability": "^0.2.1",
"@vercel/analytics": "^1.6.1",
"@vercel/speed-insights": "^1.3.1",
"@vercel/toolbar": "0.1.36",
Expand Down Expand Up @@ -60,4 +61,4 @@
"typescript": "^5.9.3"
},
"packageManager": "pnpm@10.19.0"
}
}
23 changes: 18 additions & 5 deletions apps/docs/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateNotFoundMarkdown, isAIAgent } from "@vercel/agent-readability";
import { precompute } from "flags/next";
import { createI18nMiddleware } from "fumadocs-core/i18n/middleware";
import { isMarkdownPreferred, rewritePath } from "fumadocs-core/negotiation";
Expand All @@ -8,7 +9,6 @@ import {
} from "next/server";
import { rootFlags } from "@/flags";
import { i18n } from "@/lib/geistdocs/i18n";
import { isAIAgent } from "@/lib/ai-agent-detection";
import { trackMdRequest } from "@/lib/geistdocs/md-tracking";

const { rewrite: rewriteLLM } = rewritePath(
Expand Down Expand Up @@ -65,7 +65,6 @@ const proxy = async (request: NextRequest, context: NextFetchEvent) => {
}

// AI agent detection — rewrite docs pages to markdown for agents
// so they always get structured content without needing .md URLs or Accept headers
if (
(pathname === "/docs" || pathname.startsWith("/docs/")) &&
!pathname.includes("/llms.mdx/")
Expand All @@ -88,8 +87,23 @@ const proxy = async (request: NextRequest, context: NextFetchEvent) => {
detectionMethod: agentResult.method,
})
);
return NextResponse.rewrite(new URL(result, request.nextUrl));
const response = NextResponse.rewrite(new URL(result, request.nextUrl));
response.headers.set("Vary", "Accept");
return response;
}
// Agent requested a non-existent docs URL — return helpful markdown
return new NextResponse(
generateNotFoundMarkdown(pathname, {
sitemapUrl: "/sitemap.md",
indexUrl: "/llms.txt",
}),
{
headers: {
"Content-Type": "text/markdown; charset=utf-8",
Vary: "Accept",
},
},
);
}
}

Expand All @@ -115,10 +129,9 @@ const proxy = async (request: NextRequest, context: NextFetchEvent) => {
};

export const config = {
// Matcher ignoring `/_next/`, `/api/`, static assets, favicon, sitemap, robots, etc.
matcher: [
"/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|\\.well-known/vercel/flags).*)",
],
};

export default proxy;
export default proxy;
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading