From 7851f9258fae2f54795470253df9ce4bcd5f9cb0 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 24 May 2023 10:20:06 +0100 Subject: [PATCH] fix: detect `mdx` files using full extension (#7192) --- .changeset/lazy-zebras-invent.md | 6 ++++++ packages/astro/src/content/runtime.ts | 2 +- packages/integrations/mdx/src/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/lazy-zebras-invent.md diff --git a/.changeset/lazy-zebras-invent.md b/.changeset/lazy-zebras-invent.md new file mode 100644 index 000000000000..1c2abb981edb --- /dev/null +++ b/.changeset/lazy-zebras-invent.md @@ -0,0 +1,6 @@ +--- +'@astrojs/mdx': patch +'astro': patch +--- + +Detect `mdx` files using their full extension diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index f38d9192a263..9187c4fced77 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -306,7 +306,7 @@ async function render({ let props = baseProps; // Auto-apply MDX components export - if (id.endsWith('mdx')) { + if (id.endsWith('.mdx')) { props = { components: mod.components ?? {}, ...baseProps, diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 3e1f84c0a3c6..0d1ff9d1337a 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -94,7 +94,7 @@ export default function mdx(partialMdxOptions: Partial = {}): AstroI // Override transform to alter code before MDX compilation // ex. inject layouts async transform(_, id) { - if (!id.endsWith('mdx')) return; + if (!id.endsWith('.mdx')) return; // Read code from file manually to prevent Vite from parsing `import.meta.env` expressions const { fileId } = getFileInfo(id, config);