Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove legacy mdx content collections handler #7353

Merged
merged 6 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
}>;
}
}`,
};