diff --git a/packages/website-ue/src/core/api/server.ts b/packages/website-ue/src/core/api/server.ts index 68771c57c..9f8c1d1ff 100644 --- a/packages/website-ue/src/core/api/server.ts +++ b/packages/website-ue/src/core/api/server.ts @@ -3,7 +3,7 @@ import { sluggify } from "@blitzkit/core"; import type { RemoteStorageComponent } from "@protos/blitz_static_remote_storage_component"; import { parse } from "yaml"; import type { Tank } from "../../protos/tank"; -import type { TankListEntry } from "../../protos/tank_list"; +import type { TankList, TankListEntry } from "../../protos/tank_list"; import type { Tanks } from "../../protos/tanks"; import { AbstractAPI } from "./abstract"; @@ -120,15 +120,13 @@ export class ServerAPI extends AbstractAPI { const data: Tanks = { tanks: {} }; for (const { id } of tankList.list) { - console.log(id); - data.tanks[id] = await this.tank(id); + data.tanks[id] = await this._tank(id, tankList); } return data; } - async tank(id: string) { - const tankList = await this.tankList(); + async _tank(id: string, tankList: TankList) { const tankListEntry = tankList.list.find((tank) => tank.id === id); if (!tankListEntry) { @@ -142,4 +140,9 @@ export class ServerAPI extends AbstractAPI { return { tank, compensation, slug } satisfies Tank; } + + async tank(id: string) { + const tankList = await this.tankList(); + return this._tank(id, tankList); + } } diff --git a/packages/website-ue/src/pages/tanks/[slug]/index.astro b/packages/website-ue/src/pages/tanks/[slug]/index.astro index 3b6cea110..f657bf588 100644 --- a/packages/website-ue/src/pages/tanks/[slug]/index.astro +++ b/packages/website-ue/src/pages/tanks/[slug]/index.astro @@ -6,9 +6,9 @@ import BaseLayout from "../../../layouts/BaseLayout.astro"; import { Page } from "./_index"; export const getStaticPaths = (async () => { - const { tanks } = await api.tanks(); + const { list } = await api.tankList(); - return tanks.map((tank) => ({ + return list.map((tank) => ({ params: { slug: tank.slug }, props: { id: tank.id }, })); diff --git a/packages/website-ue/src/pages/tanks/index.astro b/packages/website-ue/src/pages/tanks/index.astro index f7706b2af..fe7888999 100644 --- a/packages/website-ue/src/pages/tanks/index.astro +++ b/packages/website-ue/src/pages/tanks/index.astro @@ -3,14 +3,14 @@ import "@radix-ui/colors/violet-dark.css"; import { api } from "../../core/api/dynamic"; import BaseLayout from "../../layouts/BaseLayout.astro"; -const tanksList = await api.tanks(); +const tankList = await api.tankList(); ---

tanks

{ - tanksList.tanks.map(({ id, slug }) => ( + tankList.list.map(({ id, slug }) => (

{slug} ({id})