diff --git a/packages/astro-ghostcms/index.ts b/packages/astro-ghostcms/index.ts index d4a1c3ec..27c836bb 100644 --- a/packages/astro-ghostcms/index.ts +++ b/packages/astro-ghostcms/index.ts @@ -45,7 +45,13 @@ const IC = { /** INTERNAL STRING */ F0FR: "Inject `/404` Route", /** INTERNAL STRING */ - RSS: "Injecting `/rss.xml` Route and `@astrojs/rss` Integration" + RSS: "Injecting `/rss.xml` Route and `@astrojs/rss` Integration", + /** INTERNAL STRING */ + NOURL: "No Ghost URL defined in User Config: Falling back to environment variables.", + /** INTERNAL STRING */ + id404: "404 Injection Disabled", + /** INTERNAL STRING */ + idRSS: "RSS Injection Disabled" } /** CONTENT API ENVIRONMENT VARIABLES */ @@ -81,7 +87,9 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { dCO: GhostConfig.disableConsoleOutput, SM: GhostConfig.sitemap, RTXT: GhostConfig.robotstxt, - gSite: GhostConfig.ghostURL + gSite: GhostConfig.ghostURL, + dRSS: GhostConfig.disableRSS, + d404: GhostConfig.disable404 } // Check For ENV Variables @@ -93,8 +101,9 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { throw IC.KEY_MISSING; } // CHECK FOR API URL - if(ENV.CONTENT_API_URL === undefined){ - if(GCD.gSite === undefined){ + if(GCD.gSite === undefined){ + logger.warn(IC.NOURL) + if(ENV.CONTENT_API_URL === undefined){ logger.error(IC.URL_MISSING); throw IC.URL_MISSING; } @@ -114,17 +123,21 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { // DEFAULT PROGRAM ROUTES if( !GCD.dCO ) { logger.info( IC.IDR )} - if( !GCD.dCO ) { logger.info( IC.F0FR )} - injectRoute({ - pattern: '/404', - entrypoint: `${IC.PKG}/404.astro` - }); + if( !GCD.d404 ){ + if( !GCD.dCO ) { logger.info( IC.F0FR )} + injectRoute({ + pattern: '/404', + entrypoint: `${IC.PKG}/404.astro` + }); + } else { if( !GCD.dCO ) { logger.info(IC.id404)}} - if( !GCD.dCO ) { logger.info( IC.RSS )} - injectRoute({ - pattern: '/rss.xml', - entrypoint: `${IC.PKG}/rss.xml.ts` - }); + if( !GCD.dRSS ) { + if( !GCD.dCO ) { logger.info( IC.RSS )} + injectRoute({ + pattern: '/rss.xml', + entrypoint: `${IC.PKG}/rss.xml.ts` + }); + } else { if( !GCD.dCO ) { logger.info(IC.idRSS)}} // THEME ROUTES if( !GCD.dCO ) { logger.info( IC.ITR )} diff --git a/packages/astro-ghostcms/src/schemas/index.ts b/packages/astro-ghostcms/src/schemas/index.ts index aa294dcc..dc60a2fe 100644 --- a/packages/astro-ghostcms/src/schemas/index.ts +++ b/packages/astro-ghostcms/src/schemas/index.ts @@ -14,13 +14,26 @@ export const UserConfigSchema = z.object({ * ], * }); */ ghostURL: z.string().url().optional(), + /** OPTIONAL - Allows the user to disable the `/rss.xml` injection */ + disableRSS: z.boolean().default(false), + /** OPTIONAL - Allows the user to disable the `/404` injection */ + disable404: z.boolean().default(false), /** OPTIONAL - Disable Route Injector * This option allows the user to disable the route injection system and utilize just the integraions other functions. Such as API, sitemap and robotstxt integrations. */ disableRouteInjection: z.boolean().default(false), - /** OPTIONAL - Allows the user to disable "info" console output */ - disableConsoleOutput: z.boolean().default(false), + /** OPTIONAL - (Default: true) Allows the user to disable "info" console output */ + disableConsoleOutput: z.boolean().default(true), /** OPTIONAL - Theme Selector - * This option allows the user to replace the included theme with an external npm module */ + * This option allows the user to replace the included theme with an external npm module + * @example + * // https://astro.build/config + * export default defineConfig({ + * integrations: [ + * ghostcms({ + * theme: "@matthiesenxyz/astro-ghostcms-theme-default" + * }) + * ], + * }); */ theme: z.string().default('@matthiesenxyz/astro-ghostcms-theme-default'), /** OPTIONAL - astrojs/sitemap * This option allows the user to configure the included integration diff --git a/playground/astro.config.mjs b/playground/astro.config.mjs index 568027ae..e5439e7e 100644 --- a/playground/astro.config.mjs +++ b/playground/astro.config.mjs @@ -6,8 +6,10 @@ export default defineConfig({ site: "https://demo.astro-ghostcms.xyz/", integrations: [ ghostcms({ - disableConsoleOutput: true, + disable404: false, + disableRSS: false, disableRouteInjection: false, + disableConsoleOutput: false, theme: "@matthiesenxyz/astro-ghostcms-theme-default", ghostURL: "https://ghostdemo.matthiesen.xyz", })