feat: backgrounds

This commit is contained in:
TrèsAbhi committed 2026-01-02 20:17:24 -06:00
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);
}