Skip to content

Commit

Permalink
Throw error if a user鈥檚 project adds MDX or sitemap integrations (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Sep 1, 2023
1 parent 1eb6262 commit 5dd22b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-olives-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': minor
---

Throw an error for duplicate MDX or sitemap integrations
13 changes: 13 additions & 0 deletions packages/starlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ export default function StarlightIntegration(opts: StarlightUserConfig): AstroIn
updateConfig(newConfig);
},

'astro:config:done': ({ config }) => {
const integrations = config.integrations.map(({ name }) => name);
for (const builtin of ['@astrojs/mdx', '@astrojs/sitemap']) {
if (integrations.filter((name) => name === builtin).length > 1) {
throw new Error(
`Found more than one instance of ${builtin}.\n` +
`Starlight includes ${builtin} by default.\n` +
'Please remove it from your integrations array in astro.config.mjs'
);
}
}
},

'astro:build:done': ({ dir }) => {
const targetDir = fileURLToPath(dir);
const cwd = dirname(fileURLToPath(import.meta.url));
Expand Down

0 comments on commit 5dd22b8

Please sign in to comment.