use relative paths for api backgrounds

This commit is contained in:
tresabhi committed 2026-06-05 11:36:47 -05:00
1 parent 516df13f62
commit c134131127
3 files changed
+9 -8

No files matched your search

+2 -3
View File
@@ -406,7 +406,7 @@ export class ServerAPI extends AbstractAPI {
@Cache()
async avatarList() {
const avatars = await this.avatars();
const list = avatars.avatars.map((avatar) => avatar.name);
const list = avatars.avatars.map((avatar) => avatar.id);
return { list };
}
@@ -414,14 +414,13 @@ export class ServerAPI extends AbstractAPI {
@Cache()
async background(id: string) {
const background = this.metadata.item(id);
const name = background.name;
const stuff_ui = background.StuffUI("UIComponent");
const profile_background = background.ProfileBackground();
const sellable = background.components.sellableComponent
? background.Sellable()
: undefined;
return { name, stuff_ui, profile_background, sellable };
return { id, stuff_ui, profile_background, sellable };
}
@Cache()
@@ -5,10 +5,7 @@ import { getStaticPaths as _getStaticPaths } from "../_index";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
const { backgrounds } = await api.backgrounds();
return backgrounds.map((background) => ({
params: { id: background.name },
}));
return backgrounds.map(({ id }) => ({ params: { id } }));
});
export async function GET({ params }: APIContext<never, { id: string }>) {
@@ -1,8 +1,13 @@
import type { APIContext } from "astro";
import { api } from "../../../api/dynamic";
import { imageProxy } from "../../../api/imageProxy";
import { getStaticPaths as _getStaticPaths } from "../_index";
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
export { getStaticPaths } from "../../[api]/backgrounds/[id].json";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
const { backgrounds } = await api.backgrounds();
return backgrounds.map(({ id }) => ({ params: { id } }));
});
export async function GET({ params }: APIContext<never, { id: string }>) {
const background = await api.background(params.id);