-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V6.0.0 - Custom Apps/Games, nicer card
- Loading branch information
1 parent
e3df115
commit 07cb196
Showing
7 changed files
with
94 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
interface Props { | ||
asset: Asset; | ||
} | ||
import { Image } from "astro:assets"; | ||
import { ASSET_URL, type Asset } from "@/lib/asset"; | ||
import { Ban, CircleAlert, UserRoundPlus } from "lucide-astro"; | ||
const { asset } = Astro.props; | ||
--- | ||
|
||
<button data-asset={JSON.stringify(asset)}> | ||
<div class="flex flex-col items-center p-4 bg-secondary size-48 rounded-md space-y-4 duration-150 justify-between border-[1px] hover:border-4"> | ||
<Image loading="eager" src={ASSET_URL + asset.image} alt={asset.name} height={145} width={145} class="size-24 rounded-xl bg-accent" /> | ||
<section class="inline-flex items-center gap-2" class:list={{ "text-red-600": asset.error, "text-yellow-400": asset.partial }}> | ||
{asset.custom ? <UserRoundPlus class="size-5" /> : null} | ||
{asset.partial ? <CircleAlert class="size-5" /> : null} | ||
{asset.error ? <Ban class="size-5" /> : null} | ||
<span class="text-center font-semibold text-lg line-clamp-1"> | ||
{asset.name} | ||
</span> | ||
</section> | ||
</div> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters