From f7afdb889fe4e97177958c8ec92f80c5f6e5cb51 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Fri, 12 Aug 2022 17:17:26 -0500 Subject: [MDX] Fix remaining inconsistencies with Markdown (#4268) * feat: add "file" and "url" to layout props * feat: add rawContent and compiledContent errs * fix: add "file" and "url" to frontmatter * fix: add separate MDX instance type * types: add MarkdownLayoutProps and MDXLayoutProps * refactor: simplify MDXLayoutProps * test: pass file and url to layout * test: glob components with .default and Content * feat: add to MDX * feat: declare MDX type module * fix: [MD] move file and url to layout props only * chore: changeset * chore: bump MDX to "minor" with more details * refactor: remove "file" + "url" top-level props (save for minor) * revert: MDInstance type def updates (save for minor) * fix: MDXInstance "default" + "content" types * fix: bad test layout * chore: remove getHeaders fro *.mdx --- .../fixtures/mdx-component/src/pages/glob.astro | 11 +++++ .../mdx-frontmatter/src/layouts/Base.astro | 8 +++- .../integrations/mdx/test/mdx-component.test.js | 56 +++++++++++++++++++++- .../integrations/mdx/test/mdx-frontmatter.test.js | 11 +++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 packages/integrations/mdx/test/fixtures/mdx-component/src/pages/glob.astro (limited to 'packages/integrations/mdx/test') diff --git a/packages/integrations/mdx/test/fixtures/mdx-component/src/pages/glob.astro b/packages/integrations/mdx/test/fixtures/mdx-component/src/pages/glob.astro new file mode 100644 index 000000000..ae857fe27 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/mdx-component/src/pages/glob.astro @@ -0,0 +1,11 @@ +--- +const components = await Astro.glob('../components/*.mdx'); +--- + +
+ {components.map(Component => )} +
+ +
+ {components.map(({ Content }) => )} +
diff --git a/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/layouts/Base.astro b/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/layouts/Base.astro index e4fa7560a..9a1c84c9d 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/layouts/Base.astro +++ b/packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/layouts/Base.astro @@ -1,7 +1,11 @@ --- const { content = { title: "content didn't work" }, - frontmatter = { title: "frontmatter didn't work" }, + frontmatter = { + title: "frontmatter didn't work", + file: "file didn't work", + url: "url didn't work", + }, headings = [], } = Astro.props; --- @@ -18,6 +22,8 @@ const {

{content.title}

{frontmatter.title}

+

{frontmatter.file}

+

{frontmatter.url}

Layout rendered!