Enables sitemap and robots

This commit is contained in:
Adam Matthiesen 2024-01-20 06:41:22 -08:00
parent 56334232c4
commit 0552334f91
2 changed files with 18 additions and 3 deletions

View File

@ -4,6 +4,8 @@ import { UserConfigSchema, type UserConfig } from "./src/utils/UserConfigSchema"
import { ghostSitemap, ghostRobots } from "./src/integrations";
import { loadEnv } from 'vite';
import { fromZodError } from "zod-validation-error";
import sitemap from '@astrojs/sitemap';
import robotsTxt from "astro-robots-txt";
// LOAD ENVIRONMENT VARIABLES
const mode = 'all';
@ -14,12 +16,16 @@ const env = loadEnv(mode, process.cwd(), prefixes);
const pkg = '@matthiesenxyz/astro-ghostcms';
export default function GhostCMS(options: UserConfig): AstroIntegration {
let UserConfig:UserConfig
return {
name: pkg,
hooks: {
'astro:config:setup': async ({
command,
isRestart,
injectRoute,
config,
updateConfig,
logger,
}) => {
// Check For ENV Variables
@ -103,7 +109,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
logger.info("Checking for @astrojs/sitemap");
if (!int.find(({ name }) => name === '@astrojs/sitemap')) {
logger.info("Injecting Integration: @astrojs/sitemap");
int.push(ghostSitemap());
int.push(sitemap());
} else {
logger.info("Already Imported by User: @astrojs/sitemap");
}
@ -112,10 +118,19 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
logger.info("Checking for astro-robots-txt");
if (!int.find(({ name }) => name === 'astro-robots-txt')) {
logger.info("Injecting Integration: astro-robots-txt");
int.push(ghostRobots());
int.push(robotsTxt());
} else {
logger.info("Already Imported by User: astro-robots-txt");
}
try {
updateConfig({
integrations: [sitemap(),robotsTxt()]
})
} catch (e) {
logger.error(e as string)
throw e
}
},
'astro:config:done': async ({ logger }) => {

View File

@ -1,7 +1,7 @@
{
"name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
"version": "2.1.0",
"version": "2.1.1",
"author": "MatthiesenXYZ (https://matthiesen.xyz)",
"type": "module",
"license": "MIT",