This commit is contained in:
Adam Matthiesen 2024-01-26 05:43:21 -08:00
parent 110342bb96
commit 9a1b343398
3 changed files with 46 additions and 18 deletions

View File

@ -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){
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.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.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 )}

View File

@ -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

View File

@ -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",
})