refactor: import QuartzComponent and QuartzComponentProps from upstream

The local QuartzComponent/QuartzComponentProps declarations were
fully-typed-as-unknown duplicates that predated or did not use the
@quartz-community/types import. Switching to the upstream types gives
downstream consumers accurate fileData/cfg/allFiles typing in their
editor.

Kept a local RequiredOptsConstructor alias because this plugin
genuinely requires opts (repo/category/id); upstream
QuartzComponentConstructor takes 'opts?: Options' which would
accept undefined and break the runtime.
This commit is contained in:
saberzero1 2026-04-16 15:27:46 +02:00
parent aab1f76960
commit c044e071a2
No known key found for this signature in database
5 changed files with 8 additions and 38 deletions

View file

@ -1 +1,2 @@
export { Comments, CommentsOptions } from '../index.js';
import '@quartz-community/types';

File diff suppressed because one or more lines are too long

18
dist/index.d.ts vendored
View file

@ -1,19 +1,5 @@
interface QuartzComponent {
(props: QuartzComponentProps): unknown;
css?: string;
beforeDOMLoaded?: string;
afterDOMLoaded?: string;
}
type QuartzComponentProps = {
ctx: unknown;
externalResources: unknown;
fileData: unknown;
cfg: unknown;
children: unknown[];
tree: unknown;
allFiles: unknown[];
displayClass?: "mobile-only" | "desktop-only";
};
import { QuartzComponent } from '@quartz-community/types';
type CommentsOptions = {
provider: "giscus";
options: {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -1,26 +1,9 @@
import type { QuartzComponent, QuartzComponentProps } from "@quartz-community/types";
import { classNames } from "../util/lang";
// @ts-expect-error - inline script imported as string by esbuild loader
import script from "./scripts/comments.inline";
interface QuartzComponent {
(props: QuartzComponentProps): unknown;
css?: string;
beforeDOMLoaded?: string;
afterDOMLoaded?: string;
}
type QuartzComponentProps = {
ctx: unknown;
externalResources: unknown;
fileData: unknown;
cfg: unknown;
children: unknown[];
tree: unknown;
allFiles: unknown[];
displayClass?: "mobile-only" | "desktop-only";
};
type QuartzComponentConstructor<Options = undefined> = (opts: Options) => QuartzComponent;
type RequiredOptsConstructor<Options> = (opts: Options) => QuartzComponent;
export type CommentsOptions = {
provider: "giscus";
@ -81,4 +64,4 @@ export default ((opts: CommentsOptions) => {
Comments.afterDOMLoaded = script;
return Comments;
}) satisfies QuartzComponentConstructor<CommentsOptions>;
}) satisfies RequiredOptsConstructor<CommentsOptions>;