diff --git a/src/components/ModGrid.tsx b/src/components/ModGrid.tsx index 323932a..1c8bfc3 100644 --- a/src/components/ModGrid.tsx +++ b/src/components/ModGrid.tsx @@ -15,6 +15,7 @@ interface Mod { followers: number; categories: string[]; project_type: string; + source?: "modrinth" | "curseforge"; } interface ModGridProps { diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 08ff994..8bf638d 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -4,7 +4,7 @@ import Navbar from "@/components/Navbar"; import HeroSection from "@/components/HeroSection"; import ModGrid from "@/components/ModGrid"; import Footer from "@/components/Footer"; -import { getUserProjects, searchMods, getRandomKeyword } from "@/lib/api"; +import { getUserProjects, searchMods, searchCurseForge, getRandomKeyword } from "@/lib/api"; const Index = () => { const randomKeyword = useMemo(() => getRandomKeyword(), []); @@ -22,6 +22,11 @@ const Index = () => { queryFn: () => searchMods(randomKeyword, 0, 12), }); + const { data: cfData, isLoading: loadingCF } = useQuery({ + queryKey: ["curseforge-discover", randomKeyword], + queryFn: () => searchCurseForge(randomKeyword, 0, 12), + }); + const discoverMods = discoverData?.hits?.map((hit: any) => ({ id: hit.project_id, slug: hit.slug, @@ -32,6 +37,20 @@ const Index = () => { followers: hit.follows, categories: hit.categories || [], project_type: hit.project_type, + source: "modrinth" as const, + })) || []; + + const curseForgeMods = cfData?.data?.map((mod: any) => ({ + id: String(mod.id), + slug: String(mod.id), + title: mod.name, + description: mod.summary, + icon_url: mod.logo?.url, + downloads: mod.downloadCount, + followers: mod.thumbsUpCount || 0, + categories: mod.categories?.map((c: any) => c.name) || [], + project_type: "mod", + source: "curseforge" as const, })) || []; return ( @@ -50,6 +69,11 @@ const Index = () => { mods={discoverMods} isLoading={loadingDiscover} /> +