From 65f3f2b019be789c84ddb54d58b8ab055f28417e Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 10:25:51 -0800 Subject: [PATCH] Some cleanup, and change to how config options are --- packages/astro-ghostcms/README.md | 33 ++++++++++--------- packages/astro-ghostcms/src/astro-ghostcms.ts | 4 +-- .../astro-ghostcms/src/schemas/userconfig.ts | 26 +++++++++------ 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index f38c63e3..fb9eb08c 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -62,23 +62,26 @@ export default defineConfig({ integrations: [ GhostCMS({ // Config Options - ghostURL: "http://example.com"; // Recommended to set here, Can also set in .env as CONTENT_API_URL + ghostURL: "http://example.com", // Recommended to set here, Can also set in .env as CONTENT_API_URL ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. - disableThemeProvider: false; // OPTIONAL - Default False - theme: "@matthiesenxyz/astro-ghostcms-theme-default"; // OPTIONAL - Default Theme shown. + disableThemeProvider: false, // OPTIONAL - Default False + theme: "@matthiesenxyz/astro-ghostcms-theme-default", // OPTIONAL - Default Theme shown. }; - disableDefault404: false; // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. - enableRSSFeed: true; // Allows the user to Enable or disable RSS Feed Generation. Default: true - enableOGImages: true; // Allows the user to Enable or disable OG Image Generation. Default: true - fullConsoleLogs: false; // Show the full Log output from All parts of Astro-GhostCMS - robotsTxt: { - // OPTIONAL - // ADVANCED USAGE - https://www.npmjs.com/package/astro-robots-txt#configuration - } - sitemap: { - // OPTIONAL - // ADVANCED USAGE - https://docs.astro.build/en/guides/integrations-guide/sitemap - } + disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. + enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true + enableOGImages: true, // Allows the user to Enable or disable OG Image Generation. Default: true + fullConsoleLogs: false, // Show the full Log output from All parts of Astro-GhostCMS + Integrations: { + // This allows user config passthrough from Astro-GhostCMS to the Included Integrations + robotsTxt: { + // OPTIONAL + // ADVANCED USAGE - https://www.npmjs.com/package/astro-robots-txt#configuration + }, + sitemap: { + // OPTIONAL + // ADVANCED USAGE - https://docs.astro.build/en/guides/integrations-guide/sitemap + }, + }, }) ], }); diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 0579439c..f7a5f2fc 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -162,7 +162,7 @@ export default defineIntegration({ ), ); } - addIntegration(sitemap(options.sitemap)); + addIntegration(sitemap(options.Integrations?.sitemap)); } else { if (verbose) { GhostIntegrationLogger.info( @@ -181,7 +181,7 @@ export default defineIntegration({ ), ); } - addIntegration(robotsTxt(options.robotsTxt)); + addIntegration(robotsTxt(options.Integrations?.robotsTxt)); } else { if (verbose) { GhostIntegrationLogger.info( diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index c501cbd2..a475684b 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -41,18 +41,24 @@ export const GhostUserConfigSchema = z.object({ * @default true */ fullConsoleLogs: z.boolean().optional().default(false), - /** Optional - astro-robots-txt - * This option allows the user to configure the included integration + /** OPTIONAL - Integrations Configuration + * This option allows the user to configure the included integrations * Options shown are the availble options - * @see https://www.npmjs.com/package/astro-robots-txt#configuration */ - robotsTxt: z.custom().optional(), - /** OPTIONAL - astrojs/sitemap - * This option allows the user to configure the included integration - * Options shown are the availble options - * @see https://docs.astro.build/en/guides/integrations-guide/sitemap - */ - sitemap: z.custom().optional(), + Integrations: z.object({ + /** Optional - astro-robots-txt + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://www.npmjs.com/package/astro-robots-txt#configuration + */ + robotsTxt: z.custom().optional(), + /** OPTIONAL - astrojs/sitemap + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://docs.astro.build/en/guides/integrations-guide/sitemap + */ + sitemap: z.custom().optional(), + }).optional(), }); /** USER CONFIGURATION SCHEMA */