diff --git a/.changeset/blue-spiders-carry.md b/.changeset/blue-spiders-carry.md new file mode 100644 index 000000000000..a9819f5db5d6 --- /dev/null +++ b/.changeset/blue-spiders-carry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a bug where MDX files with certain characters in the name would cause builds to fail diff --git a/packages/astro/src/content/mutable-data-store.ts b/packages/astro/src/content/mutable-data-store.ts index 9587b30596a9..fdffec7cb8cc 100644 --- a/packages/astro/src/content/mutable-data-store.ts +++ b/packages/astro/src/content/mutable-data-store.ts @@ -137,7 +137,7 @@ export default new Map([${exports.join(', ')}]); // We then export them all, mapped by the import id, so we can find them again in the build. const lines: Array = []; for (const [fileName, specifier] of this.#moduleImports) { - lines.push(`['${fileName}', () => import('${specifier}')]`); + lines.push(`[${JSON.stringify(fileName)}, () => import(${JSON.stringify(specifier)})]`); } const code = ` export default new Map([\n${lines.join(',\n')}]); diff --git a/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back!.mdx b/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back!.mdx new file mode 100644 index 000000000000..a4442fb6f2bc --- /dev/null +++ b/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back!.mdx @@ -0,0 +1,16 @@ +--- +title: I'm back! +description: 'Introduction to Iguana.' +publishedDate: 'Sat May 21 2022 00:00:00 GMT-0400 (Eastern Daylight Time)' +tags: [cats, felines] +--- + +import H2 from "../src/components/H2.astro"; + +

Iguana

+ +### Iguana + +This is a rendered entry + +![file](./I'm%20back.jpg) diff --git a/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back.jpg b/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back.jpg new file mode 100644 index 000000000000..7455a726ef13 Binary files /dev/null and b/packages/astro/test/fixtures/content-layer-rendering/content-outside-src-mdx/I'm back.jpg differ