mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
update (4)
This commit is contained in:
1 parent
f85d097c16
commit
59108d7637
7 files changed
+96
-6
No files matched your search
@@ -1,17 +1,13 @@
|
||||
import {
|
||||
ClientBlitzKitAPI,
|
||||
LocalVFS,
|
||||
ServerBlitzKitAPI,
|
||||
type BlitzKitAPI,
|
||||
} from "@blitzkit/core";
|
||||
import { vfs } from "./vfs";
|
||||
|
||||
let _api: BlitzKitAPI;
|
||||
|
||||
if (import.meta.env.SSR) {
|
||||
const vfs = new LocalVFS(
|
||||
"/run/media/tresabhi/Windows/Program Files/WindowsApps/7458BE2C.WorldofTanksBlitz_11.19.272.0_x64__x4tje2y229k00",
|
||||
);
|
||||
|
||||
_api = await new ServerBlitzKitAPI(vfs).init();
|
||||
} else {
|
||||
_api = new ClientBlitzKitAPI();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import type { GetStaticPaths } from "astro";
|
||||
|
||||
export function chunkedStaticPaths(chunk: string) {
|
||||
return function () {
|
||||
const chunksEnv = assertSecret(import.meta.env.CHUNKS);
|
||||
const chunks = chunksEnv.split(",");
|
||||
|
||||
if (chunksEnv !== "*" && !chunks.includes(chunk)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [{ params: { [`chunk_${chunk}`]: chunk } }];
|
||||
} satisfies GetStaticPaths;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import type {
|
||||
GetStaticPathsItem,
|
||||
GetStaticPathsOptions,
|
||||
GetStaticPathsResult,
|
||||
} from "astro";
|
||||
|
||||
type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export function mixStaticPaths<
|
||||
TypeA extends GetStaticPathsItem,
|
||||
TypeB extends GetStaticPathsItem,
|
||||
>(
|
||||
a: (options: GetStaticPathsOptions) => Promisable<TypeA[]>,
|
||||
b: (options: GetStaticPathsOptions) => Promisable<TypeB[]>,
|
||||
) {
|
||||
return async function (options: GetStaticPathsOptions) {
|
||||
const pathsA = await a(options);
|
||||
const pathsB = await b(options);
|
||||
const paths: GetStaticPathsResult = [];
|
||||
|
||||
for (const pathA of pathsA) {
|
||||
for (const pathB of pathsB) {
|
||||
paths.push({
|
||||
params: { ...pathA.params, ...pathB.params },
|
||||
props: { ...pathA.props, ...pathB.props },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return paths as (TypeA & TypeB)[];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { LocalVFS } from "@blitzkit/core";
|
||||
|
||||
export const vfs = new LocalVFS(
|
||||
"/run/media/tresabhi/Windows/Program Files/WindowsApps/7458BE2C.WorldofTanksBlitz_11.19.272.0_x64__x4tje2y229k00",
|
||||
);
|
||||
Reference in new issue
Block a user