From 5dd22b875dc19a32c48692082fbd934e2b70da63 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 1 Sep 2023 21:54:30 +0200 Subject: Throw error if a user’s project adds MDX or sitemap integrations (#626) --- .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 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)); -- cgit