diff --git a/.changeset/shaggy-beds-itch.md b/.changeset/shaggy-beds-itch.md new file mode 100644 index 000000000000..1e925b33cf11 --- /dev/null +++ b/.changeset/shaggy-beds-itch.md @@ -0,0 +1,5 @@ +--- +'@astrojs/mdx': patch +--- + +Fix a missing newline bug when `layout` was set. diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index c8a5e515a1bc..a7abb0c33a3f 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -99,7 +99,7 @@ export default function mdx(mdxOptions: MdxOptions = {}): AstroIntegration { const frontmatter = getFrontmatter(code, id); if (frontmatter.layout) { const { layout, ...content } = frontmatter; - code += `\nexport default async function({ children }) {\nconst Layout = (await import(${JSON.stringify( + code += `\n\nexport default async function({ children }) {\nconst Layout = (await import(${JSON.stringify( frontmatter.layout )})).default;\nconst frontmatter=${JSON.stringify( content diff --git a/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/pages/index.mdx b/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/pages/index.mdx index e8815b9c3954..e6f9c8f4a689 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/pages/index.mdx +++ b/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/pages/index.mdx @@ -5,3 +5,6 @@ illThrowIfIDontExist: "Oh no, that's scary!" --- {frontmatter.illThrowIfIDontExist} + +> Note: newline intentionally missing from the end of this file. +> Useful since that can be the source of bugs in our compile step. \ No newline at end of file