mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-17 10:53:57 +01:00
update (4)
This commit is contained in:
1 parent
f85d097c16
commit
59108d7637
7 files changed
+96
-6
No files matched your search
@@ -0,0 +1,3 @@
|
||||
import { chunkedStaticPaths } from "../../core/blitzkit/chunkedStaticPaths";
|
||||
|
||||
export const getStaticPaths = chunkedStaticPaths("api");
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { APIContext, GetStaticPathsItem } from "astro";
|
||||
import sharp from "sharp";
|
||||
import { mixStaticPaths } from "../../../../core/blitzkit/mixStaticPaths";
|
||||
import { vfs } from "../../../../core/blitzkit/vfs";
|
||||
import { getStaticPaths as _getStaticPaths } from "../../_index";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
const paths: GetStaticPathsItem[] = [];
|
||||
|
||||
const circleFiles = await vfs
|
||||
.dir(`Data/Gfx/Lobby/flags`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_profile-stat_") &&
|
||||
!flag.endsWith("@2x.packed.webp"),
|
||||
),
|
||||
);
|
||||
|
||||
for (const flag of circleFiles) {
|
||||
const path = `Data/Gfx/Lobby/flags/${flag}`;
|
||||
const id = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
|
||||
|
||||
paths.push({
|
||||
params: { id },
|
||||
props: { path },
|
||||
});
|
||||
}
|
||||
|
||||
return paths;
|
||||
});
|
||||
|
||||
export async function GET({ props }: APIContext<{ path: string }>) {
|
||||
const image = sharp(await vfs.file(props.path));
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
const bytes = new Uint8Array(content);
|
||||
|
||||
return new Response(bytes);
|
||||
}
|
||||
Reference in new issue
Block a user