From 76fcdb84dd828ac373b2dc739e57fadf650820fd Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Wed, 21 Jun 2023 19:51:15 -0400 Subject: [PATCH] Chore: remove legacy mdx content collections handler (#7353) * chore: remove legacy mdx mapping * chore: changeset * chore: remove dead mdxEntryType * nit: comments on mdx pkg name Co-authored-by: Emanuele Stoppa * smol smol smol nit: and vs or --------- Co-authored-by: Emanuele Stoppa --- .changeset/six-keys-cheat.md | 5 ++++ packages/astro/src/integrations/index.ts | 10 ------- .../content-entry-type.ts | 29 ------------------- 3 files changed, 5 insertions(+), 39 deletions(-) create mode 100644 .changeset/six-keys-cheat.md diff --git a/.changeset/six-keys-cheat.md b/.changeset/six-keys-cheat.md new file mode 100644 index 000000000000..cf0c9bae5609 --- /dev/null +++ b/.changeset/six-keys-cheat.md @@ -0,0 +1,5 @@ +--- +'astro': minor +--- + +Remove legacy handling for MDX content collections. Ensure you are using `@astrojs/mdx` v0.18 or above. diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 6e27920eb89b..f0abd1576263 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -19,7 +19,6 @@ import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.j import { mergeConfig } from '../core/config/config.js'; import { info, type LogOptions } from '../core/logger/core.js'; import { isServerLikeOutput } from '../prerender/utils.js'; -import { mdxContentEntryType } from '../vite-plugin-markdown/content-entry-type.js'; async function withTakingALongTimeMsg({ name, @@ -150,15 +149,6 @@ export async function runHookConfigSetup({ logging, }); - // Add MDX content entry type to support older `@astrojs/mdx` versions - // TODO: remove in next Astro minor release - if ( - integration.name === '@astrojs/mdx' && - !updatedSettings.contentEntryTypes.find((c) => c.extensions.includes('.mdx')) - ) { - addContentEntryType(mdxContentEntryType); - } - // Add custom client directives to settings, waiting for compiled code by esbuild for (const [name, compiled] of addedClientDirectives) { updatedSettings.clientDirectives.set(name, await compiled); diff --git a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts index a3489c940132..92bb118d43a7 100644 --- a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts +++ b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts @@ -16,32 +16,3 @@ export const markdownContentEntryType: ContentEntryType = { // We need to handle propagation for Markdown because they support layouts which will bring in styles. handlePropagation: true, }; - -/** - * MDX content type for compatibility with older `@astrojs/mdx` versions - * TODO: remove in next Astro minor release - */ -export const mdxContentEntryType: ContentEntryType = { - extensions: ['.mdx'], - async getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) { - const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl)); - return { - data: parsed.data, - body: parsed.content, - slug: parsed.data.slug, - rawData: parsed.matter, - }; - }, - // MDX can import scripts and styles, - // so wrap all MDX files with script / style propagation checks - handlePropagation: true, - contentModuleTypes: `declare module 'astro:content' { - interface Render { - '.mdx': Promise<{ - Content: import('astro').MarkdownInstance<{}>['Content']; - headings: import('astro').MarkdownHeading[]; - remarkPluginFrontmatter: Record; - }>; - } -}`, -};