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