diff --git a/packages/website-ue/src/core/api/abstract.ts b/packages/website-ue/src/core/api/abstract.ts index de1a36f2b..c712bd4dd 100644 --- a/packages/website-ue/src/core/api/abstract.ts +++ b/packages/website-ue/src/core/api/abstract.ts @@ -16,4 +16,5 @@ export abstract class AbstractAPI { abstract tank(id: string): Promise; abstract avatars(): Promise; + abstract avatar(id: string): Promise; } diff --git a/packages/website-ue/src/core/api/client.ts b/packages/website-ue/src/core/api/client.ts index 487c1b16d..8069107f9 100644 --- a/packages/website-ue/src/core/api/client.ts +++ b/packages/website-ue/src/core/api/client.ts @@ -6,7 +6,7 @@ import { AbstractAPI } from "./abstract"; export class ClientAPI extends AbstractAPI { tanks() { - return fetchPB("/api/tanks.pb", Tanks); + return fetchPB("/api/tanks/all.pb", Tanks); } tankList() { diff --git a/packages/website-ue/src/core/api/server.ts b/packages/website-ue/src/core/api/server.ts index 420e5d036..7bf43b0d1 100644 --- a/packages/website-ue/src/core/api/server.ts +++ b/packages/website-ue/src/core/api/server.ts @@ -150,4 +150,8 @@ export class ServerAPI extends AbstractAPI { async avatars() { return this.metadata.group("ProfileAvatarEntity"); } + + async avatar(id: string) { + return this.metadata.item(`ProfileAvatarEntity.${id}`); + } } diff --git a/packages/website-ue/src/core/tools/tools.ts b/packages/website-ue/src/core/tools/tools.ts index 4dcb9ec69..bba862ac8 100644 --- a/packages/website-ue/src/core/tools/tools.ts +++ b/packages/website-ue/src/core/tools/tools.ts @@ -17,66 +17,13 @@ export const tools: Record = { button: "purple", significant: true, }, - players: { - id: "players", - disabled: true, - button: "blue", - }, - compare: { - id: "compare", - button: "crimson", - }, - performance: { - id: "performance", - button: "jade", - }, - charts: { - id: "charts", - disabled: true, - button: "bronze", - }, - playlist: { - id: "playlist", - button: "tomato", - }, - mixer: { - id: "mixer", - button: "gray", - }, - guess: { - id: "guess", - button: "cyan", - }, - gallery: { - id: "gallery", + avatars: { + id: "avatars", button: "gold", }, - session: { - id: "session", - button: "blue", - }, - discord: { - id: "discord", - href: "https://discord.com/application-directory/1097673957865443370", - button: "indigo", - }, - tier_list: { - id: "tier-list", - strings: "tier_list", - button: "orange", - }, - embed: { - id: "embed", - button: "red", - }, api: { id: "api", disabled: true, button: "bronze", }, - more: { - id: "more", - href: "https://discord.gg/nDt7AjGJQH", - button: "plum", - }, }; diff --git a/packages/website-ue/src/pages/api/avatars/[id].webp.ts b/packages/website-ue/src/pages/api/avatars/[id].webp.ts new file mode 100644 index 000000000..a53bfa200 --- /dev/null +++ b/packages/website-ue/src/pages/api/avatars/[id].webp.ts @@ -0,0 +1,27 @@ +import type { APIContext, GetStaticPaths } from "astro"; +import { api } from "../../../core/api/dynamic"; + +export const getStaticPaths = (async () => { + const avatars = await api.avatars(); + + return avatars.map((avatar) => ({ + params: { id: avatar.name }, + })); +}) satisfies GetStaticPaths; + +/** + * One day I will write documentation for this + */ +export async function GET({ params }: APIContext) { + const avatar = await api.avatar(params.id); + const profileAvatar = avatar.ProfileAvatar(); + + if (import.meta.env.DEV) { + return Response.redirect(profileAvatar.avatar); + } + + const response = await fetch(profileAvatar.avatar); + const buffer = await response.arrayBuffer(); + + return new Response(buffer); +} diff --git a/packages/website-ue/src/pages/api/tanks.json.ts b/packages/website-ue/src/pages/api/tanks/all.json.ts similarity index 75% rename from packages/website-ue/src/pages/api/tanks.json.ts rename to packages/website-ue/src/pages/api/tanks/all.json.ts index 9cf1b6f33..482f98ed2 100644 --- a/packages/website-ue/src/pages/api/tanks.json.ts +++ b/packages/website-ue/src/pages/api/tanks/all.json.ts @@ -1,4 +1,4 @@ -import { api } from "../../core/api/dynamic"; +import { api } from "../../../core/api/dynamic"; /** * Literally all the tanks in one place lmao. diff --git a/packages/website-ue/src/pages/api/tanks.pb.ts b/packages/website-ue/src/pages/api/tanks/all.pb.ts similarity index 64% rename from packages/website-ue/src/pages/api/tanks.pb.ts rename to packages/website-ue/src/pages/api/tanks/all.pb.ts index 241a6f65f..8246d17ee 100644 --- a/packages/website-ue/src/pages/api/tanks.pb.ts +++ b/packages/website-ue/src/pages/api/tanks/all.pb.ts @@ -1,5 +1,5 @@ -import { api } from "../../core/api/dynamic"; -import { Tanks } from "../../protos/tanks"; +import { api } from "../../../core/api/dynamic"; +import { Tanks } from "../../../protos/tanks"; /** * Literally all the tanks in one place lmao. diff --git a/packages/website-ue/src/pages/avatars/index.astro b/packages/website-ue/src/pages/avatars/index.astro index 87f608929..ae715cd78 100644 --- a/packages/website-ue/src/pages/avatars/index.astro +++ b/packages/website-ue/src/pages/avatars/index.astro @@ -24,7 +24,7 @@ const avatars = await api.avatars(); {ui.obtaining_methods &&

{ui.obtaining_methods}

} {ui.features &&

{ui.features}

} - + {avatar.components.sellableComponent && (
{JSON.stringify(avatar.Sellable(), null, 2)}
diff --git a/packages/website-ue/src/pages/index.astro b/packages/website-ue/src/pages/index.astro index 577a646c7..4700907d3 100644 --- a/packages/website-ue/src/pages/index.astro +++ b/packages/website-ue/src/pages/index.astro @@ -1,6 +1,7 @@ --- import "@radix-ui/colors/amber-dark.css"; import packageJson from "../../../../package.json"; +import { tools } from "../core/tools/tools"; import BaseLayout from "../layouts/BaseLayout.astro"; --- @@ -9,9 +10,11 @@ import BaseLayout from "../layouts/BaseLayout.astro";

blitzkit {packageJson.version}

-

/tanks

- -

/avatars

- -

/api

+ { + Object.values(tools).map((tool) => ( +

+ {tool.id} +

+ )) + }