diff options
author | Chris Swithinbank | 2023-09-01 21:54:30 +0200 |
---|---|---|
committer | GitHub | 2023-09-01 21:54:30 +0200 |
commit | 5dd22b875dc19a32c48692082fbd934e2b70da63 (patch) | |
tree | 327a3d308275438920e89399d9b9b45bde69328e | |
parent | 1eb6262ac885a39c6c41a5b1f90b3117a1f30a91 (diff) | |
download | IT.starlight-5dd22b875dc19a32c48692082fbd934e2b70da63.tar.gz IT.starlight-5dd22b875dc19a32c48692082fbd934e2b70da63.tar.bz2 IT.starlight-5dd22b875dc19a32c48692082fbd934e2b70da63.zip |
Throw error if a userโs project adds MDX or sitemap integrations (#626)
-rw-r--r-- | .changeset/brown-olives-share.md | 5 | ||||
-rw-r--r-- | packages/starlight/index.ts | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/.changeset/brown-olives-share.md b/.changeset/brown-olives-share.md new file mode 100644 index 00000000..cd825954 --- /dev/null +++ b/.changeset/brown-olives-share.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': minor +--- + +Throw an error for duplicate MDX or sitemap integrations diff --git a/packages/starlight/index.ts b/packages/starlight/index.ts index 4e7cba3d..2198f13f 100644 --- a/packages/starlight/index.ts +++ b/packages/starlight/index.ts @@ -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)); |