mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
module icons
This commit is contained in:
1 parent
e5e747f7a0
commit
aaae8fb8ff
2 files changed
+40
-34
No files matched your search
@@ -0,0 +1,40 @@
|
||||
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 files = await vfs
|
||||
.dir(`Data/Gfx/UI/ModulesTechTree`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(file) =>
|
||||
!file.endsWith("@2x.packed.webp") && file.startsWith("vehicle"),
|
||||
),
|
||||
);
|
||||
|
||||
for (const file of files) {
|
||||
const nameRaw = file.match(/vehicle(.+)\.packed\.webp/)![1];
|
||||
const id = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
||||
const path = `Data/Gfx/UI/ModulesTechTree/${file}`;
|
||||
|
||||
paths.push({
|
||||
params: { id },
|
||||
props: { path },
|
||||
});
|
||||
}
|
||||
|
||||
return paths;
|
||||
});
|
||||
|
||||
export async function GET({ props }: APIContext<{ path: string }>) {
|
||||
const buffer = await sharp(await vfs.file(props.path))
|
||||
.trim()
|
||||
.toBuffer();
|
||||
const bytes = new Uint8Array(buffer);
|
||||
|
||||
return new Response(bytes);
|
||||
}
|
||||
Reference in new issue
Block a user