From c7efcf57e00a0fcde3bc9f813e3cc59902bd484c Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Thu, 4 Aug 2022 23:12:07 -0700 Subject: [PATCH] fix missing newline bug in mdx (#4145) --- .changeset/shaggy-beds-itch.md | 5 +++++ packages/integrations/mdx/src/index.ts | 2 +- .../mdx/test/fixtures/mdx-frontmatter/src/pages/index.mdx | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/shaggy-beds-itch.md diff --git a/.changeset/shaggy-beds-itch.md b/.changeset/shaggy-beds-itch.md new file mode 100644 index 000000000..1e925b33c --- /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 c8a5e515a..a7abb0c33 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 e8815b9c3..e6f9c8f4a 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