From 5dd22b875dc19a32c48692082fbd934e2b70da63 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 1 Sep 2023 21:54:30 +0200 Subject: [PATCH] =?UTF-8?q?Throw=20error=20if=20a=20user=E2=80=99s=20proje?= =?UTF-8?q?ct=20adds=20MDX=20or=20sitemap=20integrations=20(#626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/brown-olives-share.md | 5 +++++ packages/starlight/index.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .changeset/brown-olives-share.md diff --git a/.changeset/brown-olives-share.md b/.changeset/brown-olives-share.md new file mode 100644 index 0000000000..cd82595449 --- /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 4e7cba3dbd..2198f13fc1 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));