mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 15:52:55 +01:00
feat: backgrounds
This commit is contained in:
1 parent
437bee4a85
commit
0209d48475
5 files changed
+83
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import type { APIContext, GetStaticPaths } from "astro";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
const backgrounds = await api.backgrounds();
|
||||
|
||||
return backgrounds.map((avatar) => ({
|
||||
params: { id: avatar.name },
|
||||
}));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
/**
|
||||
* One day I will write documentation for this
|
||||
*/
|
||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||
const avatar = await api.background(params.id);
|
||||
const profileBackground = avatar.ProfileBackground();
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
return Response.redirect(profileBackground.background);
|
||||
}
|
||||
|
||||
const response = await fetch(profileBackground.background);
|
||||
const buffer = await response.arrayBuffer();
|
||||
|
||||
return new Response(buffer);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
import { Grade } from "@protos/blitz_static_standard_grades_enum";
|
||||
import { api } from "../../core/api/dynamic";
|
||||
import BaseLayout from "../../layouts/BaseLayout.astro";
|
||||
|
||||
const backgrounds = await api.backgrounds();
|
||||
---
|
||||
|
||||
<BaseLayout accent="amber">
|
||||
{
|
||||
backgrounds.map((background) => {
|
||||
const ui = background.StuffUI("UIComponent");
|
||||
const profileBackground = background.ProfileBackground();
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3>
|
||||
{ui.display_name} {Grade[ui.grade]}{" "}
|
||||
</h3>
|
||||
|
||||
<pre>{JSON.stringify(profileBackground, null, 2)}</pre>
|
||||
|
||||
{ui.description && <p>{ui.description}</p>}
|
||||
{ui.obtaining_methods && <p>{ui.obtaining_methods}</p>}
|
||||
{ui.features && <p>{ui.features}</p>}
|
||||
|
||||
<img width="128" src={`/api/backgrounds/${background.name}.webp`} />
|
||||
|
||||
{background.components.sellableComponent && (
|
||||
<pre>{JSON.stringify(background.Sellable(), null, 2)}</pre>
|
||||
)}
|
||||
|
||||
<br />
|
||||
</>
|
||||
);
|
||||
})
|
||||
}
|
||||
</BaseLayout>
|
||||
Reference in new issue
Block a user