feat: load tank data

This commit is contained in:
TrèsAbhi committed 2025-11-28 14:21:26 -06:00
1 parent 6a958da390
commit 383d3a36ef
3 files changed
+39 -1

No files matched your search

@@ -1,3 +1,4 @@
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
import type { Tanks } from "../../protos/tanks";
export abstract class AbstractAPI {
@@ -7,4 +8,6 @@ export abstract class AbstractAPI {
locale: string,
prefix?: string
): Promise<Record<string, string>>;
abstract tank(id: string): Promise<TankCatalogComponent>;
}
+13 -1
View File
@@ -78,7 +78,12 @@ export class ServerAPI extends AbstractAPI {
for (const item of group) {
const tankCatalog = item.TankCatalog();
const name = strings[tankCatalog.name!.value];
if (!tankCatalog.name) continue;
const name = strings[tankCatalog.name.value];
if (!name) continue;
const id = item.name;
const slug = sluggify(name);
@@ -88,4 +93,11 @@ export class ServerAPI extends AbstractAPI {
return { tanks };
}
async tank(id: string) {
const item = this.metadata.item(`TankEntity.${id}`);
const tankCatalog = item.TankCatalog();
return tankCatalog;
}
}
@@ -0,0 +1,23 @@
---
import type { GetStaticPaths } from "astro";
import { api } from "../../../core/api/dynamic";
export const getStaticPaths = (async () => {
const { tanks } = await api.tanks();
return tanks.map((tank) => ({
params: { slug: tank.slug },
props: { id: tank.id },
}));
}) satisfies GetStaticPaths;
const { id } = Astro.props;
---
<h1>Tank {id}</h1>
<div style="max-height: 40rem; overflow-y: scroll">
<code>
<pre>{JSON.stringify( await api.tank(id) , null, 2)}</pre>
</code>
</div>