From 9d8e9466138a5f55446e99dc40778bbdf2d27352 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 24 May 2023 10:00:21 +0100 Subject: [PATCH] fix: detect `mdx` files using full extension --- .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 2ccf6626654b..7e8d17e3d066 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -95,7 +95,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);