mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 15:52:55 +01:00
feat: meta section
This commit is contained in:
1 parent
1d3cb95b89
commit
40a1eb861d
14 files changed
+141
-18
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { Nation } from "@protos/blitz_static_tank_component";
|
||||
import type { APIContext, GetStaticPaths } from "astro";
|
||||
|
||||
const enums = {
|
||||
nation: Nation,
|
||||
};
|
||||
|
||||
export const getStaticPaths = (() => {
|
||||
return Object.keys(enums).map((name) => ({ params: { enum: name } }));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
/**
|
||||
* The one who wipes, swipes.
|
||||
*/
|
||||
export function GET({
|
||||
params,
|
||||
}: APIContext<never, { enum: keyof typeof enums }>) {
|
||||
const map: Record<number, string> = {};
|
||||
|
||||
for (const key in enums[params.enum]) {
|
||||
const value = enums[params.enum][key];
|
||||
if (typeof value !== "string") continue;
|
||||
map[key] = value;
|
||||
}
|
||||
|
||||
return Response.json(map);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import type { APIContext, GetStaticPaths } from "astro";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { Tank } from "../../../protos/tank";
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
const { tanks } = await api.tanks();
|
||||
@@ -13,5 +13,5 @@ export const getStaticPaths = (async () => {
|
||||
*/
|
||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||
const tank = await api.tank(params.id);
|
||||
return new Response(TankCatalogComponent.encode(tank).finish());
|
||||
return new Response(Tank.encode(tank).finish());
|
||||
}
|
||||
@@ -17,13 +17,13 @@ export function Page({ id }: { id: string }) {
|
||||
}
|
||||
|
||||
function Content({ id }: { id: string }) {
|
||||
const tank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
const { tank, compensation } = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
|
||||
Tankopedia.useInitialization(tank.upgrade_stages.length);
|
||||
Tankopedia.useInitialization(tank!.upgrade_stages.length);
|
||||
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const { characteristics, parameters } = useMemo(
|
||||
() => computeCharacteristics(tank, protagonist),
|
||||
() => computeCharacteristics(id, tank!, compensation!, protagonist),
|
||||
[protagonist]
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ function Content({ id }: { id: string }) {
|
||||
<br />
|
||||
|
||||
<div style={{ display: "flex", flexWrap: "wrap" }}>
|
||||
{times(tank.upgrade_stages.length + 1, (index) => (
|
||||
{times(tank!.upgrade_stages.length + 1, (index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() => {
|
||||
|
||||
Reference in new issue
Block a user