Skip to content

Commit

Permalink
Enables sitemap and robots
Browse files Browse the repository at this point in the history
  • Loading branch information
Adammatthiesen committed Jan 20, 2024
1 parent 5633423 commit 0552334
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand 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
Expand Down Expand Up @@ -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");
}
Expand All @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0552334

Please sign in to comment.