Skip to content

Commit

Permalink
fix: use correct type for verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
shepherdjerred committed Aug 4, 2024
1 parent a970c22 commit 8876098
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { AstroIntegration } from "astro";
import type { IntegrationInput, IntegrationOptions } from "./types.js";
import type { IntegrationDefaults, IntegrationInput, IntegrationOptions } from "./types.js";
import { buildDoneHook } from "./hook.js";

const defaults = {
const defaults: IntegrationDefaults = {
width: 1200,
height: 630,
verbose: false,
};

export function astroOpenGraphImages({ options, render }: IntegrationInput): AstroIntegration {
Expand Down
25 changes: 16 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ import type { AstroIntegrationLogger, RouteData } from "astro";
import type { ReactNode } from "react";

export interface IntegrationInput {
options: DefaultIntegrationOptions;
options: PartialIntegrationOptions;
render: RenderFunction;
}

export type DefaultIntegrationOptions = Omit<Omit<SatoriOptions, "width">, "height"> & {
width?: number;
height?: number;
verbose: boolean;
};

export type IntegrationOptions = DefaultIntegrationOptions & {
/** When applied to PartialIntegrationOptions this type equals IntegrationOptions */
export interface IntegrationDefaults {
width: number;
height: number;
verbose: boolean;
};
}

/**
* IntegrationOptions with some optional properties. This is what we expose to the user. It allows us to
* merge the defaults with the user's options and ensure that all required properties are present.
*/
export type PartialIntegrationOptions = Omit<Omit<SatoriOptions, "width">, "height"> & Partial<IntegrationDefaults>;

/**
* The options that we use internally. This ensures that all options are configured, either with something
* the user provided or with a default value.
*/
export type IntegrationOptions = PartialIntegrationOptions & IntegrationDefaults;

/** This is the page data passed in by Astro */
export interface Page {
Expand Down

0 comments on commit 8876098

Please sign in to comment.