more helpers....
This commit is contained in:
parent
aea8305ac0
commit
e0372288ed
|
@ -143,32 +143,16 @@ export default defineIntegration({
|
||||||
c.bold(c.magenta("Configuring Enabled Integrations")),
|
c.bold(c.magenta("Configuring Enabled Integrations")),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Theme Provider
|
// Local Integration Helper
|
||||||
if (!options.ThemeProvider?.disableThemeProvider) {
|
const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => {
|
||||||
addIntegration(
|
if (enabled) {
|
||||||
ghostThemeProvider({
|
addIntegration(integration);
|
||||||
theme: options.ThemeProvider?.theme,
|
} else {
|
||||||
verbose,
|
intLogInfo(c.gray(`${name} integration is disabled`));
|
||||||
}),
|
}
|
||||||
);
|
|
||||||
} else {
|
|
||||||
intLogInfo(c.gray("Theme Provider is disabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Satori OG Images
|
|
||||||
if (options.enableOGImages) {
|
|
||||||
addIntegration(ghostOGImages({ verbose }));
|
|
||||||
} else {
|
|
||||||
intLogInfo(c.gray("OG Image Provider is disabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// RSS Feed
|
|
||||||
if (options.enableRSSFeed) {
|
|
||||||
addIntegration(ghostRSS({ verbose }));
|
|
||||||
} else {
|
|
||||||
intLogInfo(c.gray("RSS Feed is disabled"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check External Integration Helper
|
||||||
const checkIntegration = (name: string, integration: AstroIntegration) => {
|
const checkIntegration = (name: string, integration: AstroIntegration) => {
|
||||||
if (!hasIntegration(name)) {
|
if (!hasIntegration(name)) {
|
||||||
intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`)));
|
intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`)));
|
||||||
|
@ -178,6 +162,41 @@ export default defineIntegration({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject Route Helper
|
||||||
|
const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => {
|
||||||
|
if (enabled) {
|
||||||
|
routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`)));
|
||||||
|
injectRoute({
|
||||||
|
pattern: pattern,
|
||||||
|
entrypoint: `${name}${entrypoint}`,
|
||||||
|
prerender: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
localIntegration(
|
||||||
|
!options.ThemeProvider?.disableThemeProvider,
|
||||||
|
"Theme Provider",
|
||||||
|
ghostThemeProvider({
|
||||||
|
theme: options.ThemeProvider?.theme,
|
||||||
|
verbose,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
localIntegration(
|
||||||
|
options.enableOGImages,
|
||||||
|
"Satori OG Images",
|
||||||
|
ghostOGImages({ verbose })
|
||||||
|
);
|
||||||
|
|
||||||
|
localIntegration(
|
||||||
|
options.enableRSSFeed,
|
||||||
|
"RSS Feed",
|
||||||
|
ghostRSS({ verbose })
|
||||||
|
);
|
||||||
|
|
||||||
checkIntegration(
|
checkIntegration(
|
||||||
"@astrojs/sitemap",
|
"@astrojs/sitemap",
|
||||||
sitemap(options.Integrations?.sitemap)
|
sitemap(options.Integrations?.sitemap)
|
||||||
|
@ -187,18 +206,12 @@ export default defineIntegration({
|
||||||
robotsTxt(options.Integrations?.robotsTxt)
|
robotsTxt(options.Integrations?.robotsTxt)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
routeHelper(
|
||||||
// Set up default 404 page
|
"Default 404 Page",
|
||||||
if (!options.disableDefault404) {
|
!options.disableDefault404,
|
||||||
routeLogInfo(c.bold(c.cyan("Setting up default 404 page")));
|
"/404",
|
||||||
injectRoute({
|
"/404.astro"
|
||||||
pattern: "/404",
|
);
|
||||||
entrypoint: `${name}/404.astro`,
|
|
||||||
prerender: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
routeLogInfo(c.gray("Default 404 page is disabled, Skipping..."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add virtual imports for user configuration
|
// Add virtual imports for user configuration
|
||||||
addVirtualImports({
|
addVirtualImports({
|
||||||
|
|
Loading…
Reference in New Issue