mirror of
https://github.com/quartz-community/runtime.git
synced 2026-07-22 02:50:26 +00:00
38 lines
1 KiB
TypeScript
38 lines
1 KiB
TypeScript
import type { BuildCtx } from "@jackyzha0/quartz/util/ctx";
|
|
import type { QuartzConfig } from "@jackyzha0/quartz/cfg";
|
|
import type { ProcessedContent, QuartzPluginData } from "@jackyzha0/quartz/plugins/vfile";
|
|
import { VFile } from "vfile";
|
|
|
|
type BuildCtxOverrides = Omit<Partial<BuildCtx>, "argv"> & {
|
|
argv?: Partial<BuildCtx["argv"]>;
|
|
};
|
|
|
|
export const createCtx = (overrides: BuildCtxOverrides = {}): BuildCtx => {
|
|
const { argv: argvOverrides, ...rest } = overrides;
|
|
const argv: BuildCtx["argv"] = {
|
|
directory: "content",
|
|
verbose: false,
|
|
output: "dist",
|
|
serve: false,
|
|
watch: false,
|
|
port: 0,
|
|
wsPort: 0,
|
|
...argvOverrides,
|
|
};
|
|
|
|
return {
|
|
buildId: "test-build",
|
|
argv,
|
|
cfg: {} as QuartzConfig,
|
|
allSlugs: [],
|
|
allFiles: [],
|
|
incremental: false,
|
|
...rest,
|
|
};
|
|
};
|
|
|
|
export const createProcessedContent = (data: Partial<QuartzPluginData> = {}): ProcessedContent => {
|
|
const vfile = new VFile("");
|
|
vfile.data = data;
|
|
return [{ type: "root", children: [] }, vfile];
|
|
};
|