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);
|
||||
}
|
||||
Reference in new issue
Block a user