Skip to content

Commit ceef82a

Browse files
committed
Fix build: use @ path alias, fix layout config, simplify search API
1 parent 7a81e40 commit ceef82a

File tree

5 files changed

+31
-116
lines changed

5 files changed

+31
-116
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// @ts-nocheck -- skip type checking
2-
import * as docs_14 from "../content/sponsor.mdx?collection=docs&hash=1765003858214"
3-
import * as docs_13 from "../content/license.mdx?collection=docs&hash=1765003858214"
4-
import * as docs_12 from "../content/introduction.mdx?collection=docs&hash=1765003858214"
5-
import * as docs_11 from "../content/index.mdx?collection=docs&hash=1765003858214"
6-
import * as docs_10 from "../content/getting-started.mdx?collection=docs&hash=1765003858214"
7-
import * as docs_9 from "../content/faqs.mdx?collection=docs&hash=1765003858214"
8-
import * as docs_8 from "../content/error-handling.mdx?collection=docs&hash=1765003858214"
9-
import * as docs_7 from "../content/ecosystem.mdx?collection=docs&hash=1765003858214"
10-
import * as docs_6 from "../content/data-models.mdx?collection=docs&hash=1765003858214"
11-
import * as docs_5 from "../content/configuration.mdx?collection=docs&hash=1765003858214"
12-
import * as docs_4 from "../content/community-support.mdx?collection=docs&hash=1765003858214"
13-
import * as docs_3 from "../content/basic-usage.mdx?collection=docs&hash=1765003858214"
14-
import * as docs_2 from "../content/authentication.mdx?collection=docs&hash=1765003858214"
15-
import * as docs_1 from "../content/api.mdx?collection=docs&hash=1765003858214"
16-
import * as docs_0 from "../content/ai-services.mdx?collection=docs&hash=1765003858214"
2+
import * as docs_14 from "../content/sponsor.mdx?collection=docs&hash=1765003858000"
3+
import * as docs_13 from "../content/license.mdx?collection=docs&hash=1765003858000"
4+
import * as docs_12 from "../content/introduction.mdx?collection=docs&hash=1765003858000"
5+
import * as docs_11 from "../content/index.mdx?collection=docs&hash=1765003858000"
6+
import * as docs_10 from "../content/getting-started.mdx?collection=docs&hash=1765003858000"
7+
import * as docs_9 from "../content/faqs.mdx?collection=docs&hash=1765003858000"
8+
import * as docs_8 from "../content/error-handling.mdx?collection=docs&hash=1765003858000"
9+
import * as docs_7 from "../content/ecosystem.mdx?collection=docs&hash=1765003858000"
10+
import * as docs_6 from "../content/data-models.mdx?collection=docs&hash=1765003858000"
11+
import * as docs_5 from "../content/configuration.mdx?collection=docs&hash=1765003858000"
12+
import * as docs_4 from "../content/community-support.mdx?collection=docs&hash=1765003858000"
13+
import * as docs_3 from "../content/basic-usage.mdx?collection=docs&hash=1765003858000"
14+
import * as docs_2 from "../content/authentication.mdx?collection=docs&hash=1765003858000"
15+
import * as docs_1 from "../content/api.mdx?collection=docs&hash=1765003858000"
16+
import * as docs_0 from "../content/ai-services.mdx?collection=docs&hash=1765003858000"
1717
import { _runtime } from "fumadocs-mdx"
1818
import * as _source from "../source.config"
19-
export const docs = _runtime.doc<typeof _source.docs>([{ info: {"path":"ai-services.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/ai-services.mdx"}, data: docs_0 }, { info: {"path":"api.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/api.mdx"}, data: docs_1 }, { info: {"path":"authentication.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/authentication.mdx"}, data: docs_2 }, { info: {"path":"basic-usage.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/basic-usage.mdx"}, data: docs_3 }, { info: {"path":"community-support.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/community-support.mdx"}, data: docs_4 }, { info: {"path":"configuration.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/configuration.mdx"}, data: docs_5 }, { info: {"path":"data-models.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/data-models.mdx"}, data: docs_6 }, { info: {"path":"ecosystem.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/ecosystem.mdx"}, data: docs_7 }, { info: {"path":"error-handling.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/error-handling.mdx"}, data: docs_8 }, { info: {"path":"faqs.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/faqs.mdx"}, data: docs_9 }, { info: {"path":"getting-started.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/getting-started.mdx"}, data: docs_10 }, { info: {"path":"index.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/index.mdx"}, data: docs_11 }, { info: {"path":"introduction.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/introduction.mdx"}, data: docs_12 }, { info: {"path":"license.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/license.mdx"}, data: docs_13 }, { info: {"path":"sponsor.mdx","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/sponsor.mdx"}, data: docs_14 }]);
20-
export const meta = _runtime.meta<typeof _source.meta>([{ info: {"path":"meta.json","absolutePath":"D:/Project - Devoloper/RUNcode/UrbanReflex/docs/urban-reflex/content/meta.json"}, data: {"title":"Documentation","pages":["index","introduction","---Getting Started---","getting-started","basic-usage","---Reference---","api","data-models","ai-services","authentication","error-handling","---Resources---","ecosystem","configuration","---","faqs","sponsor","community-support","license"]} }]);
19+
export const docs = _runtime.doc<typeof _source.docs>([{ info: {"path":"ai-services.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/ai-services.mdx"}, data: docs_0 }, { info: {"path":"api.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/api.mdx"}, data: docs_1 }, { info: {"path":"authentication.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/authentication.mdx"}, data: docs_2 }, { info: {"path":"basic-usage.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/basic-usage.mdx"}, data: docs_3 }, { info: {"path":"community-support.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/community-support.mdx"}, data: docs_4 }, { info: {"path":"configuration.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/configuration.mdx"}, data: docs_5 }, { info: {"path":"data-models.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/data-models.mdx"}, data: docs_6 }, { info: {"path":"ecosystem.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/ecosystem.mdx"}, data: docs_7 }, { info: {"path":"error-handling.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/error-handling.mdx"}, data: docs_8 }, { info: {"path":"faqs.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/faqs.mdx"}, data: docs_9 }, { info: {"path":"getting-started.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/getting-started.mdx"}, data: docs_10 }, { info: {"path":"index.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/index.mdx"}, data: docs_11 }, { info: {"path":"introduction.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/introduction.mdx"}, data: docs_12 }, { info: {"path":"license.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/license.mdx"}, data: docs_13 }, { info: {"path":"sponsor.mdx","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/sponsor.mdx"}, data: docs_14 }]);
20+
export const meta = _runtime.meta<typeof _source.meta>([{ info: {"path":"meta.json","absolutePath":"D:/Dev/UrbanReflex/docs/documentation/content/meta.json"}, data: {"title":"Documentation","pages":["index","introduction","---Getting Started---","getting-started","basic-usage","---Reference---","api","data-models","ai-services","authentication","error-handling","---Resources---","ecosystem","configuration","---","faqs","sponsor","community-support","license"]} }]);

docs/documentation/app/api/search/route.ts

Lines changed: 12 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,29 @@
2020
* ============================================================================
2121
*/
2222

23-
import { NextRequest, NextResponse } from "next/server";
23+
import { NextResponse } from "next/server";
2424
import { source } from "@/app/source";
2525

26-
export async function GET(request: NextRequest) {
27-
const searchParams = request.nextUrl.searchParams;
28-
const query = searchParams.get("query");
29-
30-
if (!query || query.trim().length === 0) {
31-
return NextResponse.json([]);
32-
}
26+
export const dynamic = "force-static";
27+
export const revalidate = 3600; // Revalidate every hour
3328

29+
// Pre-generate search index at build time
30+
export async function GET() {
3431
try {
3532
// Get all pages from source using generateParams
3633
const params = await source.generateParams();
37-
const queryLower = query.toLowerCase().trim();
38-
const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 0);
3934

40-
// Get all pages from params
41-
const allPages = params
35+
// Build search index
36+
const searchIndex = params
4237
.map((param) => {
4338
try {
4439
const slug = param.slug || [];
4540
const page = source.getPage(slug);
4641
if (page) {
4742
return {
48-
data: page.data,
43+
id: page.url,
44+
title: page.data.title || "",
45+
description: page.data.description || "",
4946
url: page.url,
5047
};
5148
}
@@ -56,88 +53,10 @@ export async function GET(request: NextRequest) {
5653
return null;
5754
})
5855
.filter((page): page is NonNullable<typeof page> => page !== null);
59-
60-
console.log("Total pages found:", allPages.length);
61-
62-
// Search implementation - search in title, description, and headings
63-
const results = allPages
64-
.map((page) => {
65-
const title = page.data.title || "";
66-
const description = page.data.description || "";
67-
const url = page.url;
68-
69-
// Get headings from TOC if available
70-
const headings = page.data.toc?.map((item: any) => item.title).join(" ") || "";
71-
72-
// Combine all searchable text
73-
const searchableText = `${title} ${description} ${headings}`.toLowerCase();
74-
75-
// Calculate relevance score
76-
let score = 0;
77-
78-
// Exact title match gets highest score
79-
if (title.toLowerCase() === queryLower) {
80-
score += 100;
81-
} else if (title.toLowerCase().startsWith(queryLower)) {
82-
score += 50;
83-
} else if (title.toLowerCase().includes(queryLower)) {
84-
score += 30;
85-
}
86-
87-
// Word matching in title
88-
queryWords.forEach((word) => {
89-
if (title.toLowerCase().includes(word)) {
90-
score += 10;
91-
}
92-
});
93-
94-
// Description matching
95-
if (description.toLowerCase().includes(queryLower)) {
96-
score += 20;
97-
}
98-
queryWords.forEach((word) => {
99-
if (description.toLowerCase().includes(word)) {
100-
score += 5;
101-
}
102-
});
103-
104-
// Heading matching
105-
queryWords.forEach((word) => {
106-
if (headings.toLowerCase().includes(word)) {
107-
score += 8;
108-
}
109-
});
110-
111-
// General text matching
112-
if (searchableText.includes(queryLower)) {
113-
score += 1;
114-
}
115-
116-
if (score > 0) {
117-
return {
118-
id: url, // Use URL as unique ID for React key
119-
title,
120-
description: description || "No description available",
121-
url,
122-
};
123-
}
124-
return null;
125-
})
126-
.filter((item): item is NonNullable<typeof item> => item !== null)
127-
.sort((a, b) => {
128-
// Sort by title alphabetically for same score
129-
return a.title.localeCompare(b.title);
130-
})
131-
.slice(0, 10); // Limit to 10 results
13256

133-
console.log("Search results count:", results.length);
134-
135-
// Return direct array - Fumadocs expects array directly
136-
const response = Array.isArray(results) ? results : [];
137-
console.log("Returning response:", response.length, "items");
138-
return NextResponse.json(response);
57+
return NextResponse.json(searchIndex);
13958
} catch (error) {
140-
console.error("Search error:", error);
59+
console.error("Search index generation error:", error);
14160
return NextResponse.json([]);
14261
}
14362
}

docs/documentation/app/layout.config.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,4 @@ export const baseOptions: BaseLayoutProps = {
5252
external: true,
5353
},
5454
],
55-
search: {
56-
provider: "api",
57-
api: "/api/search",
58-
},
5955
};

docs/documentation/components/ui/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import * as React from "react"
2424
import { Slot } from "@radix-ui/react-slot"
2525
import { cva, type VariantProps } from "class-variance-authority"
26-
import { cn } from "../../lib/utils"
26+
import { cn } from "@/lib/utils"
2727

2828
const buttonVariants = cva(
2929
"inline-flex items-center justify-center gap-2 whitespace-nowrap font-bold text-sm transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",

docs/documentation/components/ui/card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import * as React from "react"
24-
import { cn } from "../../lib/utils"
24+
import { cn } from "@/lib/utils"
2525

2626
const Card = React.forwardRef<
2727
HTMLDivElement,

0 commit comments

Comments
 (0)