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 <my.burning@gmail.com>

* smol smol smol nit: and vs or

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
Ben Holmes 2023-06-21 19:51:15 -04:00 committed by GitHub
parent 3f9f5c117e
commit 76fcdb84dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 39 deletions

View file

@ -0,0 +1,5 @@
---
'astro': minor
---
Remove legacy handling for MDX content collections. Ensure you are using `@astrojs/mdx` v0.18 or above.

View file

@ -19,7 +19,6 @@ import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.j
import { mergeConfig } from '../core/config/config.js'; import { mergeConfig } from '../core/config/config.js';
import { info, type LogOptions } from '../core/logger/core.js'; import { info, type LogOptions } from '../core/logger/core.js';
import { isServerLikeOutput } from '../prerender/utils.js'; import { isServerLikeOutput } from '../prerender/utils.js';
import { mdxContentEntryType } from '../vite-plugin-markdown/content-entry-type.js';
async function withTakingALongTimeMsg<T>({ async function withTakingALongTimeMsg<T>({
name, name,
@ -150,15 +149,6 @@ export async function runHookConfigSetup({
logging, 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 // Add custom client directives to settings, waiting for compiled code by esbuild
for (const [name, compiled] of addedClientDirectives) { for (const [name, compiled] of addedClientDirectives) {
updatedSettings.clientDirectives.set(name, await compiled); updatedSettings.clientDirectives.set(name, await compiled);

View file

@ -16,32 +16,3 @@ export const markdownContentEntryType: ContentEntryType = {
// We need to handle propagation for Markdown because they support layouts which will bring in styles. // We need to handle propagation for Markdown because they support layouts which will bring in styles.
handlePropagation: true, 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>;
}>;
}
}`,
};