mirror of
https://github.com/quartz-community/comments.git
synced 2026-07-22 02:50:28 +00:00
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:
parent
aab1f76960
commit
c044e071a2
5 changed files with 8 additions and 38 deletions
1
dist/components/index.d.ts
vendored
1
dist/components/index.d.ts
vendored
|
|
@ -1 +1,2 @@
|
|||
export { Comments, CommentsOptions } from '../index.js';
|
||||
import '@quartz-community/types';
|
||||
|
|
|
|||
2
dist/components/index.js.map
vendored
2
dist/components/index.js.map
vendored
File diff suppressed because one or more lines are too long
18
dist/index.d.ts
vendored
18
dist/index.d.ts
vendored
|
|
@ -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
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue