fix: detect mdx files using full extension (#7192)

This commit is contained in:
Emanuele Stoppa 2023-05-24 10:20:06 +01:00 committed by GitHub
parent 27c6e01826
commit 7851f9258f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,6 @@
---
'@astrojs/mdx': patch
'astro': patch
---
Detect `mdx` files using their full extension

View file

@ -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,

View file

@ -94,7 +94,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): 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);