mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
faded flags
This commit is contained in:
1 parent
9e4d9c7968
commit
85883cd2c5
2 files changed
+36
-5
No files matched your search
@@ -0,0 +1,35 @@
|
|||||||
|
import type { APIContext, GetStaticPathsItem } from "astro";
|
||||||
|
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 fadedFiles = await vfs
|
||||||
|
.dir(`Data/Gfx/Lobby/flags`)
|
||||||
|
.then((files) =>
|
||||||
|
files.filter(
|
||||||
|
(flag) =>
|
||||||
|
flag.startsWith("flag_filter_") && flag.endsWith("@2x.packed.webp"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const flag of fadedFiles) {
|
||||||
|
const path = `Data/Gfx/Lobby/flags/${flag}`;
|
||||||
|
const id = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
|
||||||
|
|
||||||
|
paths.push({
|
||||||
|
params: { id },
|
||||||
|
props: { path },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function GET({ props }: APIContext<{ path: string }>) {
|
||||||
|
const bytes = new Uint8Array(await vfs.file(props.path));
|
||||||
|
|
||||||
|
return new Response(bytes);
|
||||||
|
}
|
||||||
@@ -32,9 +32,5 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
|||||||
export async function GET({ props }: APIContext<{ path: string }>) {
|
export async function GET({ props }: APIContext<{ path: string }>) {
|
||||||
const bytes = new Uint8Array(await vfs.file(props.path));
|
const bytes = new Uint8Array(await vfs.file(props.path));
|
||||||
|
|
||||||
return new Response(bytes, {
|
return new Response(bytes);
|
||||||
headers: {
|
|
||||||
"Content-Type": "image/webp",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user