+
+
Apps
+
- {
- apps.map((app) => (
-
- ))
- }
+ {[...customApps, ...apps].map((app) =>
)}
diff --git a/src/pages/api/add-asset.ts b/src/pages/api/add-asset.ts
new file mode 100644
index 0000000..56c617f
--- /dev/null
+++ b/src/pages/api/add-asset.ts
@@ -0,0 +1,28 @@
+import type { Asset } from "@/lib/asset";
+import type { APIRoute } from "astro";
+
+export const PUT: APIRoute = async ({ cookies, request }) => {
+ const body = (await request.json()) as {
+ type: string;
+ name: string;
+ link: string;
+ };
+ if (!body.type || !body.name || !body.link) {
+ return Response.json({ error: "Missing required fields" }, { status: 400 });
+ }
+ if (!["app", "game"].includes(body.type)) {
+ return Response.json({ error: "Invalid asset type" }, { status: 400 });
+ }
+ const currentAssets: Asset[] = cookies.get(`asset.${body.type}`)?.json() || [];
+ currentAssets.push({
+ name: body.name,
+ link: body.link,
+ image: "/media/icons/custom.webp",
+ custom: true,
+ });
+ cookies.set(`asset.${body.type}`, JSON.stringify(currentAssets), {
+ path: "/",
+ expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
+ });
+ return Response.json({ success: true });
+};
diff --git a/src/pages/ga.astro b/src/pages/ga.astro
index 051b1c8..dbf565e 100644
--- a/src/pages/ga.astro
+++ b/src/pages/ga.astro
@@ -1,33 +1,24 @@
---
-import { Image } from "astro:assets";
-import Obfuscated from "@/components/Obfuscated.astro";
+import AssetCard from "@/components/AssetCard.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/asset";
-import { Gamepad2 } from "lucide-astro";
+import { Gamepad2, PlusCircle } from "lucide-astro";
const games: Asset[] = await (await fetch(`${ASSET_URL}/json/games.json`)).json();
+const customGames = (Astro.cookies.get("asset.game")?.json() as Asset[]) ?? [];
---
-
-
+
+
Games
+
- {
- games.map((game) => (
-
- ))
- }
+ {[...customGames, ...games].map((game) =>
)}
diff --git a/src/pages/to.astro b/src/pages/to.astro
index 39646e5..54d58eb 100644
--- a/src/pages/to.astro
+++ b/src/pages/to.astro
@@ -1,6 +1,5 @@
---
-import { Image } from "astro:assets";
-import Obfuscated from "@/components/Obfuscated.astro";
+import AssetCard from "@/components/AssetCard.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/asset";
import { Wrench } from "lucide-astro";
@@ -14,16 +13,7 @@ const tools: Asset[] = await (await fetch(`${ASSET_URL}/json/tools.json`)).json(
Tools
- {
- tools.map((tool) => (
-
- ))
- }
+ {tools.map((tool) =>
)}