Added CurseForge edge proxy
Co-authored-by: felix-fx-top <253056634+felix-fx-top@users.noreply.github.com>
This commit is contained in:
parent
226712c011
commit
02fe60178a
@ -15,6 +15,7 @@ interface Mod {
|
|||||||
followers: number;
|
followers: number;
|
||||||
categories: string[];
|
categories: string[];
|
||||||
project_type: string;
|
project_type: string;
|
||||||
|
source?: "modrinth" | "curseforge";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ModGridProps {
|
interface ModGridProps {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import Navbar from "@/components/Navbar";
|
|||||||
import HeroSection from "@/components/HeroSection";
|
import HeroSection from "@/components/HeroSection";
|
||||||
import ModGrid from "@/components/ModGrid";
|
import ModGrid from "@/components/ModGrid";
|
||||||
import Footer from "@/components/Footer";
|
import Footer from "@/components/Footer";
|
||||||
import { getUserProjects, searchMods, getRandomKeyword } from "@/lib/api";
|
import { getUserProjects, searchMods, searchCurseForge, getRandomKeyword } from "@/lib/api";
|
||||||
|
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
const randomKeyword = useMemo(() => getRandomKeyword(), []);
|
const randomKeyword = useMemo(() => getRandomKeyword(), []);
|
||||||
@ -22,6 +22,11 @@ const Index = () => {
|
|||||||
queryFn: () => searchMods(randomKeyword, 0, 12),
|
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) => ({
|
const discoverMods = discoverData?.hits?.map((hit: any) => ({
|
||||||
id: hit.project_id,
|
id: hit.project_id,
|
||||||
slug: hit.slug,
|
slug: hit.slug,
|
||||||
@ -32,6 +37,20 @@ const Index = () => {
|
|||||||
followers: hit.follows,
|
followers: hit.follows,
|
||||||
categories: hit.categories || [],
|
categories: hit.categories || [],
|
||||||
project_type: hit.project_type,
|
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 (
|
return (
|
||||||
@ -50,6 +69,11 @@ const Index = () => {
|
|||||||
mods={discoverMods}
|
mods={discoverMods}
|
||||||
isLoading={loadingDiscover}
|
isLoading={loadingDiscover}
|
||||||
/>
|
/>
|
||||||
|
<ModGrid
|
||||||
|
title="إضافات CurseForge 🟠"
|
||||||
|
mods={curseForgeMods}
|
||||||
|
isLoading={loadingCF}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user