Skip to content

Commit a8f5a3a

Browse files
committed
feat: improve search api
1 parent 0864cd2 commit a8f5a3a

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

islands/SearchComponent.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Code,
55
ExternalLink,
66
FileText,
7+
Home,
78
MessageSquare,
89
Search,
910
X,
@@ -14,7 +15,7 @@ interface SearchResult {
1415
title: string;
1516
url: string;
1617
excerpt: string;
17-
type: "doc" | "api" | "example" | "blog" | "std";
18+
type: "doc" | "api" | "example" | "blog" | "std" | "page";
1819
score: number;
1920
highlights: SearchHighlight[];
2021
// label from server (e.g. "Docs", "Std", "API")
@@ -194,6 +195,8 @@ export default function SearchComponent({
194195
return <FileText size={16} class="text-green" />;
195196
case "blog":
196197
return <MessageSquare size={16} class="text-mauve" />;
198+
case "page":
199+
return <Home size={16} class="text-pink" />;
197200
default:
198201
return <BookOpen size={16} class="text-text" />;
199202
}
@@ -207,6 +210,8 @@ export default function SearchComponent({
207210
return "Example";
208211
case "blog":
209212
return "Blog";
213+
case "page":
214+
return "Page";
210215
default:
211216
return "Docs";
212217
}

routes/api/search.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface SearchResult {
1111
title: string;
1212
url: string;
1313
excerpt: string;
14-
type: "doc" | "api" | "example" | "blog" | "std";
14+
type: "doc" | "api" | "example" | "blog" | "std" | "page";
1515
label: string;
1616
score: number;
1717
highlights: string[];
@@ -71,6 +71,9 @@ async function buildIndex(): Promise<SearchResult[]> {
7171
return indexCache;
7272
}
7373

74+
// Reset Orama DB to prevent duplicate document errors
75+
oramaDb = null;
76+
7477
const items: RawIndexItem[] = [];
7578

7679
try {
@@ -220,6 +223,72 @@ async function buildIndex(): Promise<SearchResult[]> {
220223
console.warn("Failed to index std repo:", e);
221224
}
222225

226+
// Index static pages (home, satellites, etc.)
227+
try {
228+
// Home page
229+
items.push({
230+
title: "Andromeda - Modern JavaScript & TypeScript Runtime",
231+
url: "/",
232+
excerpt:
233+
"A modern, fast, and secure JavaScript & TypeScript runtime built from the ground up in Rust. Zero-config TypeScript support, hardware-accelerated graphics, comprehensive Web APIs, and developer-first tooling.",
234+
type: "page",
235+
keywords: [
236+
"home",
237+
"andromeda",
238+
"javascript",
239+
"typescript",
240+
"runtime",
241+
"rust",
242+
"nova engine",
243+
"gpu accelerated",
244+
"memory safe",
245+
"wintertc",
246+
],
247+
body:
248+
"Andromeda JavaScript TypeScript runtime Rust Nova Engine zero config GPU accelerated memory safe WinterTC compliant fast secure modern developer tooling Web APIs hardware acceleration",
249+
headings: ["Andromeda", "Features", "Installation", "Getting Started"],
250+
});
251+
252+
// Satellites page
253+
items.push({
254+
title: "Andromeda Satellites",
255+
url: "/satellites",
256+
excerpt:
257+
"Lightweight, purpose-built executables designed for containerized environments and microservice architectures. Each satellite focuses on a single capability for optimal performance.",
258+
type: "page",
259+
keywords: [
260+
"satellites",
261+
"containers",
262+
"docker",
263+
"microservices",
264+
"serverless",
265+
"ci/cd",
266+
"andromeda-run",
267+
"andromeda-fmt",
268+
"andromeda-lint",
269+
"andromeda-check",
270+
"andromeda-compile",
271+
"andromeda-bundle",
272+
],
273+
body:
274+
"satellites lightweight executables containers docker microservices serverless functions lambda cold start CI/CD pipeline build tools andromeda-run andromeda-fmt andromeda-lint andromeda-check andromeda-compile andromeda-bundle smaller images faster startup better security",
275+
headings: [
276+
"Satellites",
277+
"Why Satellites",
278+
"Smaller Images",
279+
"Faster Startup",
280+
"Better Security",
281+
"Common Use Cases",
282+
"Serverless Functions",
283+
"CI/CD Pipeline",
284+
"Build Containers",
285+
"Development Tools",
286+
],
287+
});
288+
} catch (e) {
289+
console.warn("Failed to index static pages:", e);
290+
}
291+
223292
const results: SearchResult[] = items.map((it) => ({
224293
title: it.title,
225294
url: it.url,
@@ -235,6 +304,8 @@ async function buildIndex(): Promise<SearchResult[]> {
235304
return "Blog";
236305
case "std":
237306
return "Std";
307+
case "page":
308+
return "Page";
238309
default:
239310
return "Docs";
240311
}
@@ -282,6 +353,8 @@ async function buildIndex(): Promise<SearchResult[]> {
282353
return "Blog";
283354
case "std":
284355
return "Std";
356+
case "page":
357+
return "Page";
285358
default:
286359
return "Docs";
287360
}
@@ -554,6 +627,8 @@ export const handler = {
554627
return "Blog";
555628
case "std":
556629
return "Std";
630+
case "page":
631+
return "Page";
557632
default:
558633
return "Docs";
559634
}

0 commit comments

Comments
 (0)