cleanup
This commit is contained in:
parent
b7566e5625
commit
54e3b3fe76
|
@ -10,7 +10,7 @@ import { viteGhostCMS } from "./src/virtual";
|
|||
const IC = {
|
||||
/** INTERNAL PACKAGE NAME */
|
||||
PKG:'@matthiesenxyz/astro-ghostcms',
|
||||
/** INTERNAL PACKAGE NAME */
|
||||
/** INTERNAL PACKAGE NAME (THEME) */
|
||||
DT:'@matthiesenxyz/astro-ghostcms-theme-default',
|
||||
/** INTERNAL STRING */
|
||||
CHECK_ENV:"Checking for Environment Variables...",
|
||||
|
@ -25,7 +25,9 @@ const IC = {
|
|||
/** INTERNAL STRING */
|
||||
IT:"Injecting Theme: ",
|
||||
/** INTERNAL STRING */
|
||||
IR:"Injecting Routes...",
|
||||
IDR:"Injecting Default Routes...",
|
||||
/** INTERNAL STRING */
|
||||
IR:"Injecting Default Theme Routes...",
|
||||
/** INTERNAL STRING */
|
||||
IRD:"Route Injection Disabled - Skipping...",
|
||||
/** INTERNAL STRING */
|
||||
|
@ -38,6 +40,10 @@ const IC = {
|
|||
CF:"Checking for ",
|
||||
/** INTERNAL STRING */
|
||||
CONFSETUPDONE:"GhostCMS Injection Complete. Integration is now ready.",
|
||||
/** INTERNAL STRING */
|
||||
F0FR: "Inject `/404` Route",
|
||||
/** INTERNAL STRING */
|
||||
RSS: "Injecting `/rss.xml` Route and `@astrojs/rss` Integration"
|
||||
}
|
||||
|
||||
/** CONTENT API ENVIRONMENT VARIABLES */
|
||||
|
@ -57,6 +63,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
|
|||
updateConfig,
|
||||
logger,
|
||||
}) => {
|
||||
|
||||
// CHECK USER CONFIG AND MAKE AVAILBLE TO INTEGRATIONS
|
||||
logger.info("Checking Config...")
|
||||
const o = UserConfigSchema.safeParse(options || {}) as SafeParseSuccess<UserConfig>;
|
||||
|
@ -65,6 +72,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
|
|||
logger.error(`Config Error - ${ validationError }`);
|
||||
throw validationError;
|
||||
}
|
||||
|
||||
/** INTERNAL USERCONFIG ALIAS */
|
||||
const uconf = o.data;
|
||||
/** CONFIG OPTION: ROUTE INJECTION */
|
||||
|
@ -89,6 +97,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
|
|||
}
|
||||
|
||||
if(!injection){
|
||||
|
||||
// THEME SELECTOR
|
||||
if ( entry === IC.DT ) {
|
||||
if( !logs ) { logger.info( IC.IT + IC.DT )}
|
||||
|
@ -97,68 +106,44 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
|
|||
}
|
||||
|
||||
// INJECT ROUTES
|
||||
if(!logs) {logger.info(IC.IR)}
|
||||
|
||||
injectRoute({
|
||||
pattern: '/',
|
||||
entrypoint: `${entry}/index.astro`
|
||||
});
|
||||
// DEFAULT PROGRAM ROUTES
|
||||
if( !logs ) { logger.info( IC.IDR )}
|
||||
|
||||
injectRoute({
|
||||
pattern: '/404',
|
||||
entrypoint: IC.PKG+'/404.astro'
|
||||
});
|
||||
if( !logs ) { logger.info( IC.F0FR )}
|
||||
injectRoute({ pattern: '/404', entrypoint: IC.PKG+'/404.astro' });
|
||||
|
||||
injectRoute({
|
||||
pattern: '/[slug]',
|
||||
entrypoint: `${entry}/[slug].astro`
|
||||
});
|
||||
if( !logs ) { logger.info( IC.RSS )}
|
||||
injectRoute({ pattern: '/rss.xml', entrypoint: IC.PKG+'/rss.xml.ts' });
|
||||
|
||||
injectRoute({
|
||||
pattern: '/tags',
|
||||
entrypoint: `${entry}/tags.astro`
|
||||
});
|
||||
// THEME ROUTES
|
||||
if( !logs ) { logger.info( IC.ITR )}
|
||||
|
||||
injectRoute({
|
||||
pattern: '/authors',
|
||||
entrypoint: `${entry}/authors.astro`
|
||||
});
|
||||
injectRoute({ pattern: '/', entrypoint: `${entry}/index.astro` });
|
||||
|
||||
injectRoute({
|
||||
pattern: '/tag/[slug]',
|
||||
entrypoint: `${entry}/tag/[slug].astro`
|
||||
});
|
||||
injectRoute({ pattern: '/[slug]', entrypoint: `${entry}/[slug].astro` });
|
||||
|
||||
injectRoute({
|
||||
pattern: '/author/[slug]',
|
||||
entrypoint: `${entry}/author/[slug].astro`
|
||||
});
|
||||
injectRoute({ pattern: '/tags', entrypoint: `${entry}/tags.astro` });
|
||||
|
||||
injectRoute({
|
||||
pattern: '/archives/[...page]',
|
||||
entrypoint: `${entry}/archives/[...page].astro`
|
||||
});
|
||||
} else {
|
||||
if(!logs) {logger.info(IC.IRD)}
|
||||
}
|
||||
injectRoute({ pattern: '/authors', entrypoint: `${entry}/authors.astro` });
|
||||
|
||||
injectRoute({ pattern: '/tag/[slug]', entrypoint: `${entry}/tag/[slug].astro` });
|
||||
|
||||
injectRoute({ pattern: '/author/[slug]', entrypoint: `${entry}/author/[slug].astro` });
|
||||
|
||||
injectRoute({ pattern: '/archives/[...page]', entrypoint: `${entry}/archives/[...page].astro` });
|
||||
|
||||
} else { if( !logs ) { logger.info( IC.IRD )} }
|
||||
|
||||
// IMPORT INTEGRATIONS & INTEGRATION ROUTES
|
||||
const int = [...config.integrations];
|
||||
|
||||
// IMPORT INTEGRATION: @ASTROJS/RSS
|
||||
if(!logs) {logger.info(IC.IIR + "@astrojs/rss")}
|
||||
injectRoute({
|
||||
pattern: '/rss.xml',
|
||||
entrypoint: IC.PKG+'/rss.xml.ts'
|
||||
});
|
||||
|
||||
// IMPORT INTEGRATION: @ASTROJS/SITEMAP
|
||||
if( !logs ) { logger.info( IC.CF + "@astrojs/sitemap" )}
|
||||
if ( !int.find( ({ name }) => name === '@astrojs/sitemap' )) {
|
||||
if( !logs ) { logger.info( IC.II + "@astrojs/sitemap" )}
|
||||
int.push( ghostSitemap( uconf ));
|
||||
} else {
|
||||
if(!logs) {logger.info(IC.AIbU + "@astrojs/sitemap")}
|
||||
} else { if( !logs ) { logger.info( IC.AIbU + "@astrojs/sitemap" )}
|
||||
};
|
||||
|
||||
// IMPORT INTEGRATION: ASTRO-ROBOTS-TXT
|
||||
|
@ -169,11 +154,12 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
|
|||
} else {
|
||||
if( !logs ) { logger.info( IC.AIbU + "astro-robots-txt" )}
|
||||
};
|
||||
|
||||
// FINAL STEP TO KEEP INTEGRATION LIVE
|
||||
try { updateConfig( {
|
||||
integrations: [
|
||||
ghostSitemap(uconf),
|
||||
ghostRobots(uconf),
|
||||
],
|
||||
// UPDATE ASTRO CONFIG WITH INTEGRATED INTEGRATIONS
|
||||
integrations: [ ghostSitemap( uconf ), ghostRobots( uconf ) ],
|
||||
// LOAD VITE AND SETUP viteGhostCMS Configs
|
||||
vite: { plugins: [ viteGhostCMS( uconf, config ) ]},
|
||||
}) } catch ( e ) {
|
||||
logger.error( e as string );
|
||||
|
|
Loading…
Reference in New Issue