From 24df79b1475c12ccefaadb2392e9d5911c491872 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Wed, 8 Feb 2023 15:51:44 -0500 Subject: [PATCH] wip: move mdx to collection type API --- .../src/content/blog/with-mdx.mdx | 5 ++++ examples/with-markdoc/src/pages/index.astro | 9 ++++--- packages/astro/src/content/consts.ts | 2 +- packages/integrations/mdx/src/index.ts | 24 ++++++++++++++++++- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 examples/with-markdoc/src/content/blog/with-mdx.mdx diff --git a/examples/with-markdoc/src/content/blog/with-mdx.mdx b/examples/with-markdoc/src/content/blog/with-mdx.mdx new file mode 100644 index 000000000000..d3c9d0169bac --- /dev/null +++ b/examples/with-markdoc/src/content/blog/with-mdx.mdx @@ -0,0 +1,5 @@ +--- +title: 'Example!' +--- + +# With MDX {frontmatter.title} diff --git a/examples/with-markdoc/src/pages/index.astro b/examples/with-markdoc/src/pages/index.astro index 4e7f63365177..5b8b67a9a7f6 100644 --- a/examples/with-markdoc/src/pages/index.astro +++ b/examples/with-markdoc/src/pages/index.astro @@ -5,9 +5,11 @@ import Marquee from '../components/Marquee.astro'; import { getEntryBySlug } from 'astro:content'; import RedP from '../components/RedP.astro'; -const testEntry = await getEntryBySlug('blog', 'test'); -console.log(testEntry); -const { Content } = await testEntry.render(); +const mdocEntry = await getEntryBySlug('blog', 'test'); +const mdxEntry = await getEntryBySlug('blog', 'with-mdx'); +console.log(mdocEntry); +const { Content } = await mdocEntry.render(); +const { Content: MDXContent } = await mdxEntry.render(); --- @@ -21,6 +23,7 @@ const { Content } = await testEntry.render();

Astro

+ = {}): AstroIntegration { return { name: '@astrojs/mdx', hooks: { - 'astro:config:setup': async ({ updateConfig, config, addPageExtension, command }: any) => { + 'astro:config:setup': async ({ + updateConfig, + config, + addPageExtension, + addContentEntryType, + command, + }: any) => { addPageExtension('.mdx'); + addContentEntryType(contentEntryType); const extendMarkdownConfig = partialMdxOptions.extendMarkdownConfig ?? defaultOptions.extendMarkdownConfig;