diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 88a6dc94..1ea43d48 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -177,10 +177,10 @@ export default defineIntegration({ // Setup GhostCMS Theme Provider localIntegration( - !options.ThemeProvider?.disableThemeProvider, + !options.ThemeProvider.disableThemeProvider, "Theme Provider", ghostThemeProvider({ - theme: options.ThemeProvider?.theme, + theme: options.ThemeProvider.theme, verbose, }) ); diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts index d55dd18f..e2100c3f 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -6,7 +6,7 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-rss", optionsSchema: z.object({ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts index 7b2ec601..d8cc56c3 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -6,7 +6,7 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-satoriog", optionsSchema: z.object({ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts index c43fe756..4a463756 100644 --- a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts +++ b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts @@ -6,16 +6,15 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-themeprovider", optionsSchema: z.object({ - theme: z - .string() - .optional() - .default("@matthiesenxyz/astro-ghostcms-theme-default"), - verbose: z.boolean().optional().default(false), + theme: z.string(), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { const { resolve } = createResolver(import.meta.url); + const DEFAULT_THEME = "@matthiesenxyz/astro-ghostcms-theme-default"; + return { "astro:config:setup": ({ watchIntegration, injectRoute, logger }) => { watchIntegration(resolve()); @@ -37,7 +36,7 @@ export default defineIntegration({ ); - if (options.theme === "@matthiesenxyz/astro-ghostcms-theme-default") { + if (options.theme === DEFAULT_THEME) { verboseLogsInfo( c.blue("No theme is set, injecting default theme"), ); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts index 72705928..1c394da8 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.test.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -13,6 +13,7 @@ describe("GhostUserConfigSchema", () => { enableRSSFeed: true, enableOGImages: true, verbose: false, + Integrations: {}, }; const result = GhostUserConfigSchema.safeParse(validConfig); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index 23455f06..10ad2a75 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -13,34 +13,38 @@ export const GhostUserConfigSchema = z.object({ * }) * ], * }); */ - ghostURL: z.string().url().optional(), + ghostURL: z.coerce.string().url("Must be a URL").optional(), + /** OPTIONAL - Configure the Theme Provider + * @ This option allows the user to configure the Theme Provider + */ ThemeProvider: z .object({ /** OPTIONAL - Disable the theme provider * @default false */ - disableThemeProvider: z.boolean().optional().default(false), + disableThemeProvider: z.coerce.boolean(), /** OPTIONAL - Set the theme you want to use * @default "@matthiesenxyz/astro-ghostcms-theme-default" */ - theme: z - .string() - .optional() - .default("@matthiesenxyz/astro-ghostcms-theme-default"), + theme: z.string(), }) - .optional(), + .optional() + .default({ + disableThemeProvider: false, + theme: "@matthiesenxyz/astro-ghostcms-theme-default" + }), /** Allows the user to disable the provided 404 page */ - disableDefault404: z.boolean().optional().default(false), + disableDefault404: z.coerce.boolean().optional(), /** Allows the user to disable the provided RSS Feed */ - enableRSSFeed: z.boolean().optional().default(true), + enableRSSFeed: z.coerce.boolean().optional().default(true), /** Allows the user to Enable or Disable the default Satori OG Image Generation * @default true */ - enableOGImages: z.boolean().optional().default(true), + enableOGImages: z.coerce.boolean().optional().default(true), /** Allows the user to turn on/off Full Console Logs * @default true */ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), /** OPTIONAL - Integrations Configuration * This option allows the user to configure the included integrations * Options shown are the availble options @@ -60,7 +64,7 @@ export const GhostUserConfigSchema = z.object({ */ sitemap: z.custom().optional(), }) - .optional(), + .optional().default({}), }); /** USER CONFIGURATION SCHEMA */ diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index a24919e3..56707f73 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: false, + verbose: true, }), ], });