Skip to content

Commit

Permalink
Chore: remove legacy mdx content collections handler (#7353)
Browse files Browse the repository at this point in the history
* chore: remove legacy mdx mapping

* chore: changeset

* chore: remove dead mdxEntryType

* nit: comments on mdx pkg name

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

* smol smol smol nit: and vs or

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
  • Loading branch information
bholmesdev and ematipico authored Jun 21, 2023
1 parent 3f9f5c1 commit 76fcdb8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-keys-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
---

Remove legacy handling for MDX content collections. Ensure you are using `@astrojs/mdx` v0.18 or above.
10 changes: 0 additions & 10 deletions packages/astro/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>({
name,
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 0 additions & 29 deletions packages/astro/src/vite-plugin-markdown/content-entry-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
}>;
}
}`,
};

0 comments on commit 76fcdb8

Please sign in to comment.