add verbose helper function
This commit is contained in:
parent
03c1de5591
commit
3a9ee8aa0b
|
@ -70,7 +70,7 @@ export default defineConfig({
|
||||||
disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`.
|
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
|
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
|
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
|
verbose: false, // Show the full Log output from All parts of Astro-GhostCMS
|
||||||
Integrations: {
|
Integrations: {
|
||||||
// This allows user config passthrough from Astro-GhostCMS to the Included Integrations
|
// This allows user config passthrough from Astro-GhostCMS to the Included Integrations
|
||||||
robotsTxt: {
|
robotsTxt: {
|
||||||
|
|
|
@ -25,6 +25,7 @@ const ENV = loadEnv("all", process.cwd(), "CONTENT_API");
|
||||||
|
|
||||||
// Import User Configuration Zod Schema
|
// Import User Configuration Zod Schema
|
||||||
import { GhostUserConfigSchema } from "./schemas/userconfig";
|
import { GhostUserConfigSchema } from "./schemas/userconfig";
|
||||||
|
import type { string } from "astro/zod";
|
||||||
|
|
||||||
/** Astro-GhostCMS Integration
|
/** Astro-GhostCMS Integration
|
||||||
* @description This integration allows you to use GhostCMS as a headless CMS for your Astro project
|
* @description This integration allows you to use GhostCMS as a headless CMS for your Astro project
|
||||||
|
@ -47,6 +48,8 @@ export default defineIntegration({
|
||||||
injectRoute,
|
injectRoute,
|
||||||
logger,
|
logger,
|
||||||
}) => {
|
}) => {
|
||||||
|
// Set up verbose logging
|
||||||
|
const verbose = options.verbose;
|
||||||
// Configure Loggers
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
||||||
const GhostENVLogger = logger.fork(
|
const GhostENVLogger = logger.fork(
|
||||||
|
@ -54,23 +57,35 @@ export default defineIntegration({
|
||||||
"ENV Check",
|
"ENV Check",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
// Configure Integration Loggers & verbose logging
|
||||||
const GhostIntegrationLogger = logger.fork(
|
const GhostIntegrationLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
||||||
"Integrations",
|
"Integrations",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
const intLogInfo = (message:string) => {
|
||||||
|
if (verbose) {
|
||||||
|
GhostIntegrationLogger.info(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Configure Route Logger & verbose logging
|
||||||
const GhostRouteLogger = logger.fork(
|
const GhostRouteLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
||||||
"Router",
|
"Router",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
const routeLogInfo = (message:string) => {
|
||||||
|
if (verbose) {
|
||||||
|
GhostRouteLogger.info(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Setup Watch Integration for Hot Reload during DEV
|
// Setup Watch Integration for Hot Reload during DEV
|
||||||
watchIntegration(resolve());
|
watchIntegration(resolve());
|
||||||
GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms...");
|
GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms...");
|
||||||
|
|
||||||
// Set up verbose logging
|
|
||||||
const verbose = options.fullConsoleLogs;
|
|
||||||
|
|
||||||
// Check for GhostCMS environment variables
|
// Check for GhostCMS environment variables
|
||||||
GhostENVLogger.info(
|
GhostENVLogger.info(
|
||||||
|
@ -136,77 +151,49 @@ export default defineIntegration({
|
||||||
verbose,
|
verbose,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostIntegrationLogger.info(c.gray("Theme Provider is disabled"));
|
intLogInfo(c.gray("Theme Provider is disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Satori OG Images
|
// Satori OG Images
|
||||||
if (options.enableOGImages) {
|
if (options.enableOGImages) {
|
||||||
addIntegration(ghostOGImages({ verbose }));
|
addIntegration(ghostOGImages({ verbose }));
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostIntegrationLogger.info(
|
intLogInfo(c.gray("OG Image Provider is disabled"));
|
||||||
c.gray("OG Image Provider is disabled"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RSS Feed
|
// RSS Feed
|
||||||
if (options.enableRSSFeed) {
|
if (options.enableRSSFeed) {
|
||||||
addIntegration(ghostRSS({ verbose }));
|
addIntegration(ghostRSS({ verbose }));
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostIntegrationLogger.info(c.gray("RSS Feed is disabled"));
|
intLogInfo(c.gray("RSS Feed is disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ASTROJS/SITEMAP
|
// @ASTROJS/SITEMAP
|
||||||
if (!hasIntegration("@astrojs/sitemap")) {
|
if (!hasIntegration("@astrojs/sitemap")) {
|
||||||
if (verbose) {
|
intLogInfo(c.bold(c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`)));
|
||||||
GhostIntegrationLogger.info(
|
|
||||||
c.bold(
|
|
||||||
c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
addIntegration(sitemap(options.Integrations?.sitemap));
|
addIntegration(sitemap(options.Integrations?.sitemap));
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostIntegrationLogger.info(
|
intLogInfo(c.gray("@astrojs/sitemap integration already exists, skipping..."));
|
||||||
c.gray(
|
|
||||||
"@astrojs/sitemap integration already exists, skipping...",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// ASTRO-ROBOTS-TXT
|
// ASTRO-ROBOTS-TXT
|
||||||
if (!hasIntegration("astro-robots-txt")) {
|
if (!hasIntegration("astro-robots-txt")) {
|
||||||
if (verbose) {
|
intLogInfo(c.bold(c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`)));
|
||||||
GhostIntegrationLogger.info(
|
|
||||||
c.bold(
|
|
||||||
c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
addIntegration(robotsTxt(options.Integrations?.robotsTxt));
|
addIntegration(robotsTxt(options.Integrations?.robotsTxt));
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostIntegrationLogger.info(
|
intLogInfo(c.gray("astro-robots-txt integration already exists, skipping..."));
|
||||||
c.gray(
|
|
||||||
"astro-robots-txt integration already exists, skipping...",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up default 404 page
|
// Set up default 404 page
|
||||||
if (!options.disableDefault404) {
|
if (!options.disableDefault404) {
|
||||||
if (verbose) {
|
routeLogInfo(c.bold(c.cyan("Setting up default 404 page")));
|
||||||
GhostRouteLogger.info(
|
|
||||||
c.bold(c.cyan("Setting up default 404 page")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
injectRoute({
|
injectRoute({
|
||||||
pattern: "/404",
|
pattern: "/404",
|
||||||
entrypoint: `${name}/404.astro`,
|
entrypoint: `${name}/404.astro`,
|
||||||
prerender: true,
|
prerender: true,
|
||||||
});
|
});
|
||||||
} else if (verbose) {
|
} else {
|
||||||
GhostRouteLogger.info(
|
routeLogInfo(c.gray("Default 404 page is disabled, Skipping..."));
|
||||||
c.gray("Default 404 page is disabled, Skipping..."),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add virtual imports for user configuration
|
// Add virtual imports for user configuration
|
||||||
|
|
|
@ -40,7 +40,7 @@ export const GhostUserConfigSchema = z.object({
|
||||||
/** Allows the user to turn on/off Full Console Logs
|
/** Allows the user to turn on/off Full Console Logs
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
fullConsoleLogs: z.boolean().optional().default(false),
|
verbose: z.boolean().optional().default(false),
|
||||||
/** OPTIONAL - Integrations Configuration
|
/** OPTIONAL - Integrations Configuration
|
||||||
* This option allows the user to configure the included integrations
|
* This option allows the user to configure the included integrations
|
||||||
* Options shown are the availble options
|
* Options shown are the availble options
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default defineConfig({
|
||||||
ThemeProvider: {
|
ThemeProvider: {
|
||||||
theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian",
|
theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian",
|
||||||
},
|
},
|
||||||
fullConsoleLogs: false,
|
verbose: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue