|
1 | | -import { loadAllProjects } from "@/lib/projects"; |
2 | 1 | import { ProjectGrid } from "@/components/ProjectGrid"; |
3 | 2 | import { BreadcrumbSchema } from "@/components/BreadcrumbSchema"; |
4 | 3 | import { TricolorRadar } from "@/components/TricolorRadar"; |
5 | 4 | import { MeetupIcon } from "@/components/MeetupIcon"; |
6 | 5 | import { Github, Map, Plus } from "lucide-react"; |
7 | 6 | import Link from "next/link"; |
8 | 7 | import type { Metadata } from "next"; |
| 8 | +import fs from "fs"; |
| 9 | +import path from "path"; |
9 | 10 |
|
10 | 11 | export const revalidate = 3600; // Revalidate every hour |
11 | 12 |
|
@@ -34,22 +35,10 @@ export const metadata: Metadata = { |
34 | 35 | }; |
35 | 36 |
|
36 | 37 | export default function Home() { |
37 | | - const projects = loadAllProjects(); |
38 | | - |
39 | | - // Convert to search index format |
40 | | - const searchIndex = projects.map((project) => ({ |
41 | | - slug: project.slug, |
42 | | - name: project.name, |
43 | | - short_desc: project.short_desc, |
44 | | - tags: project.tags, |
45 | | - stars: project.stars || 0, |
46 | | - primary_lang: project.primary_lang, |
47 | | - verified: project.verified || false, |
48 | | - added_at: project.added_at, |
49 | | - looking_for_contributors: project.looking_for_contributors, |
50 | | - location_city: project.location_city, |
51 | | - location_indian_state: project.location_indian_state, |
52 | | - })); |
| 38 | + // Read pre-built search index instead of parsing all TOML files |
| 39 | + // This dramatically improves TTFB (from ~14s to <0.8s) |
| 40 | + const indexPath = path.join(process.cwd(), "public", "index.json"); |
| 41 | + const searchIndex = JSON.parse(fs.readFileSync(indexPath, "utf-8")); |
53 | 42 |
|
54 | 43 | return ( |
55 | 44 | <div className="min-h-screen bg-gray-50 dark:bg-black"> |
@@ -128,7 +117,7 @@ export default function Home() { |
128 | 117 | {/* Main Content */} |
129 | 118 | <main className="container mx-auto px-4 py-8"> |
130 | 119 | {/* Search and Filters */} |
131 | | - {projects.length > 0 ? ( |
| 120 | + {searchIndex.length > 0 ? ( |
132 | 121 | <ProjectGrid initialProjects={searchIndex} /> |
133 | 122 | ) : ( |
134 | 123 | <div className="text-center py-16"> |
|
0 commit comments