Migrate types to use @quartz-community/types exports

Replace ambient quartz-compat.d.ts declarations with direct imports
from @quartz-community/types. Remove node_modules path from tsconfig
include array.
This commit is contained in:
saberzero1 2026-02-13 13:18:19 +01:00
parent f28678cb31
commit eb009bc2dc
No known key found for this signature in database
5 changed files with 35 additions and 171 deletions

35
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "0.1.0",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"@quartz-community/types": "file:../types",
"@quartz-community/utils": "github:quartz-community/utils"
},
"devDependencies": {
@ -43,6 +43,26 @@
}
}
},
"../types": {
"name": "@quartz-community/types",
"version": "0.2.0",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"preact": "^10.26.5",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
"devDependencies": {
"tsup": "^8.5.0",
"typescript": "^5.9.3"
},
"engines": {
"node": ">=22",
"npm": ">=10.9.2"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.27.3",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
@ -712,16 +732,8 @@
}
},
"node_modules/@quartz-community/types": {
"version": "0.2.0",
"resolved": "git+ssh://git@github.com/quartz-community/types.git#9b8fbbdec4a629f3b62885b0a6d7c31a40875c1c",
"license": "MIT",
"dependencies": {
"preact": "^10.26.5"
},
"engines": {
"node": ">=22",
"npm": ">=10.9.2"
}
"resolved": "../types",
"link": true
},
"node_modules/@quartz-community/utils": {
"version": "0.1.0",
@ -2990,6 +3002,7 @@
"version": "10.28.3",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.28.3.tgz",
"integrity": "sha512-tCmoRkPQLpBeWzpmbhryairGnhW9tKV6c6gr/w+RhoRoKEJwsjzipwp//1oCpGPOchvSLaAPlpcJi9MwMmoPyA==",
"dev": true,
"license": "MIT",
"funding": {
"type": "opencollective",

View file

@ -59,7 +59,7 @@
}
},
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"@quartz-community/types": "file:../types",
"@quartz-community/utils": "github:quartz-community/utils"
},
"devDependencies": {

View file

@ -27,27 +27,28 @@ export default ((opts?: Partial<BacklinksOptions>) => {
displayClass,
cfg,
}: QuartzComponentProps & { displayClass?: string }) => {
const slug = simplifySlug(fileData.slug!);
const backlinkFiles = allFiles.filter((file: { links?: string[] }) =>
file.links?.includes(slug),
);
const slug = simplifySlug(fileData.slug as string);
const locale = cfg.locale ?? "en-US";
const backlinkFiles = (
allFiles as Array<{ links?: string[]; slug?: string; frontmatter?: { title?: string } }>
).filter((file) => file.links?.includes(slug));
if (options.hideWhenEmpty && backlinkFiles.length === 0) {
return null;
}
return (
<div class={classNames(displayClass, "backlinks")}>
<h3>{i18n(cfg.locale).components.backlinks.title}</h3>
<h3>{i18n(locale).components.backlinks.title}</h3>
<OverflowList>
{backlinkFiles.length > 0 ? (
backlinkFiles.map((f: { slug?: string; frontmatter?: { title?: string } }) => (
backlinkFiles.map((f) => (
<li>
<a href={resolveRelative(fileData.slug!, f.slug!)} class="internal">
<a href={resolveRelative(fileData.slug as string, f.slug!)} class="internal">
{f.frontmatter?.title}
</a>
</li>
))
) : (
<li>{i18n(cfg.locale).components.backlinks.noBacklinksFound}</li>
<li>{i18n(locale).components.backlinks.noBacklinksFound}</li>
)}
</OverflowList>
</div>

View file

@ -21,6 +21,6 @@
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": ["src", "test", "types", "tsup.config.ts", "vitest.config.ts"],
"include": ["src", "test", "tsup.config.ts", "vitest.config.ts"],
"exclude": ["dist", "node_modules"]
}

View file

@ -1,150 +0,0 @@
declare module "@jackyzha0/quartz/components/types" {
export type QuartzComponent = unknown;
}
declare module "@jackyzha0/quartz/util/path" {
export type FilePath = string & { _brand: "FilePath" };
export type FullSlug = string & { _brand: "FullSlug" };
export function joinSegments(...segments: string[]): FilePath;
}
declare module "@jackyzha0/quartz/util/resources" {
export type JSResource =
| {
loadTime: "beforeDOMReady" | "afterDOMReady";
moduleType?: "module";
spaPreserve?: boolean;
src: string;
contentType: "external";
}
| {
loadTime: "beforeDOMReady" | "afterDOMReady";
moduleType?: "module";
spaPreserve?: boolean;
script: string;
contentType: "inline";
};
export type CSSResource = {
content: string;
inline?: boolean;
spaPreserve?: boolean;
};
export interface StaticResources {
css: CSSResource[];
js: JSResource[];
additionalHead: unknown[];
}
}
declare module "@jackyzha0/quartz/util/ctx" {
import type { QuartzConfig } from "@jackyzha0/quartz/cfg";
import type { FilePath, FullSlug } from "@jackyzha0/quartz/util/path";
export interface Argv {
directory: string;
verbose: boolean;
output: string;
serve: boolean;
watch: boolean;
port: number;
wsPort: number;
remoteDevHost?: string;
concurrency?: number;
}
export interface BuildCtx {
buildId: string;
argv: Argv;
cfg: QuartzConfig;
allSlugs: FullSlug[];
allFiles: FilePath[];
incremental: boolean;
}
}
declare module "@jackyzha0/quartz/cfg" {
export interface QuartzConfig {
configuration: {
baseUrl?: string;
};
}
}
declare module "@jackyzha0/quartz/plugins/vfile" {
import type { Root as HtmlRoot } from "hast";
import type { Root as MdRoot } from "mdast";
import type { Data, VFile } from "vfile";
export type QuartzPluginData = Data;
export type MarkdownContent = [MdRoot, VFile];
export type ProcessedContent = [HtmlRoot, VFile];
}
declare module "@jackyzha0/quartz/plugins/types" {
import type { PluggableList } from "unified";
import type { StaticResources } from "@jackyzha0/quartz/util/resources";
import type { ProcessedContent } from "@jackyzha0/quartz/plugins/vfile";
import type { QuartzComponent } from "@jackyzha0/quartz/components/types";
import type { FilePath } from "@jackyzha0/quartz/util/path";
import type { BuildCtx } from "@jackyzha0/quartz/util/ctx";
import type { VFile } from "vfile";
export interface PluginTypes {
transformers: QuartzTransformerPluginInstance[];
filters: QuartzFilterPluginInstance[];
emitters: QuartzEmitterPluginInstance[];
}
type OptionType = object | undefined;
type ExternalResourcesFn = (ctx: BuildCtx) => Partial<StaticResources> | undefined;
export type QuartzTransformerPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzTransformerPluginInstance;
export type QuartzTransformerPluginInstance = {
name: string;
textTransform?: (ctx: BuildCtx, src: string) => string;
markdownPlugins?: (ctx: BuildCtx) => PluggableList;
htmlPlugins?: (ctx: BuildCtx) => PluggableList;
externalResources?: ExternalResourcesFn;
};
export type QuartzFilterPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzFilterPluginInstance;
export type QuartzFilterPluginInstance = {
name: string;
shouldPublish(ctx: BuildCtx, content: ProcessedContent): boolean;
};
export type ChangeEvent = {
type: "add" | "change" | "delete";
path: FilePath;
file?: VFile;
};
export type QuartzEmitterPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzEmitterPluginInstance;
export type QuartzEmitterPluginInstance = {
name: string;
emit: (
ctx: BuildCtx,
content: ProcessedContent[],
resources: StaticResources,
) => Promise<FilePath[]> | AsyncGenerator<FilePath>;
partialEmit?: (
ctx: BuildCtx,
content: ProcessedContent[],
resources: StaticResources,
changeEvents: ChangeEvent[],
) => Promise<FilePath[]> | AsyncGenerator<FilePath> | null;
getQuartzComponents?: (ctx: BuildCtx) => QuartzComponent[];
externalResources?: ExternalResourcesFn;
};
}