ソースを参照

chore(dev-hub) god please fix this

Aditya Arora 2 週間 前
コミット
bf6a66bec6

+ 8 - 0
apps/developer-hub/next.config.js

@@ -1,6 +1,14 @@
 import { createMDX } from "fumadocs-mdx/next";
 
 const config = {
+  async rewrites() {
+    return [
+      {
+        source: "/docs/:path*.mdx",
+        destination: "/llms.mdx/:path*",
+      },
+    ];
+  },
   reactStrictMode: true,
   pageExtensions: ["ts", "tsx", "mdx"],
   outputFileTracingIncludes: {

+ 1 - 1
apps/developer-hub/src/app/llms.txt/route.ts

@@ -32,7 +32,7 @@ export async function GET() {
     });
   } catch (error) {
     // eslint-disable-next-line no-console
-    console.error('LLM Text route error:', error);
+    console.error("LLM Text route error:", error);
     return new NextResponse("Internal server error", { status: 500 });
   }
 }

+ 1 - 1
apps/developer-hub/src/app/mdx/[...slug]/route.ts

@@ -26,7 +26,7 @@ export async function GET(
     });
   } catch (error) {
     // eslint-disable-next-line no-console
-    console.error('MDX route error:', error);
+    console.error("MDX route error:", error);
     return new NextResponse("Internal server error", { status: 500 });
   }
 }

+ 33 - 0
apps/developer-hub/src/lib/get-llm-text.ts

@@ -1,4 +1,6 @@
+import { existsSync } from "node:fs";
 import { readFile } from "node:fs/promises";
+import path from "node:path";
 
 import type { Page } from "fumadocs-core/source";
 import { remarkInclude } from "fumadocs-mdx/config";
@@ -9,6 +11,37 @@ import remarkMdx from "remark-mdx";
 const processor = remark().use(remarkMdx).use(remarkInclude).use(remarkGfm);
 
 export async function getLLMText(page: Page) {
+  // eslint-disable-next-line no-console
+  console.error("🔥 getLLMText EXECUTED at", new Date().toISOString());
+
+  const cwd = process.cwd();
+  const abs = page.absolutePath;
+  const pathArray: string[] = Array.isArray(page.path)
+    ? page.path
+    : [page.path];
+  const repoRel = path.join(
+    cwd,
+    "apps",
+    "developer-hub",
+    "content",
+    "docs",
+    ...pathArray,
+  );
+  const appRel = path.join(cwd, "content", "docs", ...pathArray);
+
+  // eslint-disable-next-line no-console
+  console.error("🧪[LLM] url=", page.url);
+  // eslint-disable-next-line no-console
+  console.error("🧪[LLM] cwd=", cwd);
+  // eslint-disable-next-line no-console
+  console.error("🧪[LLM] abs=", abs, "exists=", abs ? existsSync(abs) : false);
+  // eslint-disable-next-line no-console
+  console.error("🧪[LLM] repoRel=", repoRel, "exists=", existsSync(repoRel));
+  // eslint-disable-next-line no-console
+  console.error("🧪[LLM] appRel=", appRel, "exists=", existsSync(appRel));
+
+  // eslint-disable-next-line no-console
+  console.error(`Getting LLM text for ${page.absolutePath}`);
   const processed = await processor.process({
     path: page.absolutePath,
     value: await readFile(page.absolutePath, "utf8"),