{"record":{"id":"7e1a735438ed5717","repo":"withastro/astro","slug":"id-astro-now-supports-mdx-support-for-compon","errorCode":null,"errorMessage":"[${id}] Astro now supports MDX! Support for components in \".md\" (or alternative extensions like \".markdown\") files using the \"setup\" frontmatter is no longer enabled by default. Migrate this file to MDX.","messagePattern":"\\[(.+?)\\] Astro now supports MDX! Support for components in \"\\.md\" \\(or alternative extensions like \"\\.markdown\"\\) files using the \"setup\" frontmatter is no longer enabled by default\\. Migrate this file to MDX\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/vite-plugin-markdown/index.ts","lineNumber":125,"sourceCode":"\t\t\t\t} = renderResult.metadata;\n\n\t\t\t\t// Add default charset for markdown pages\n\t\t\t\tconst isMarkdownPage = isPage(fileURL, settings);\n\t\t\t\tconst charset = isMarkdownPage ? '<meta charset=\"utf-8\">' : '';\n\n\t\t\t\t// Resolve all the extracted images from the content\n\t\t\t\tconst localImagePaths: MarkdownImagePath[] = [];\n\t\t\t\tfor (const imagePath of rawLocalImagePaths) {\n\t\t\t\t\tlocalImagePaths.push({\n\t\t\t\t\t\traw: imagePath,\n\t\t\t\t\t\tsafeName: shorthash(imagePath),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst { layout } = frontmatter;\n\n\t\t\t\tif (frontmatter.setup) {\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t'markdown',\n\t\t\t\t\t\t`[${id}] Astro now supports MDX! Support for components in \".md\" (or alternative extensions like \".markdown\") files using the \"setup\" frontmatter is no longer enabled by default. Migrate this file to MDX.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst code = `\n\t\t\t\timport { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(\n\t\t\t\t\tastroServerRuntimeModulePath,\n\t\t\t\t)};\n\t\t\t\timport { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};\n\t\t\t\t${layout ? `import Layout from ${JSON.stringify(layout)};` : ''}\n\n\t\t\t\t${\n\t\t\t\t\t// Only include the code relevant to `astro:assets` if there's images in the file\n\t\t\t\t\tlocalImagePaths.length > 0 || remoteImagePaths.length > 0\n\t\t\t\t\t\t? getMarkdownCodeForImages(localImagePaths, remoteImagePaths, html)\n\t\t\t\t\t\t: `const html = () => ${JSON.stringify(html)};`\n\t\t\t\t}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/vite-plugin-markdown/index.ts#L107-L143","documentation":"The markdown plugin inspects frontmatter while transforming a .md file: if a `setup` key exists it warns that the legacy feature — embedding components/scripts in markdown via setup frontmatter — is no longer enabled by default, and directs you to MDX, which supports components natively. The file still compiles as plain markdown.","triggerScenarios":"A .md (or .markdown) page/content file whose YAML frontmatter contains `setup:`, processed during dev or build. The plugin keys the warning off frontmatter.setup regardless of whether the setup code referenced Astro components.","commonSituations":"Projects dating to Astro 1/2 that used component-enhanced markdown; content authors copying old templates; after an upgrade, components in .md files silently stop rendering because the legacy pipeline is gone.","solutions":["Rename the file from .md to .mdx and replace the setup frontmatter with real MDX imports/exports at the top of the file","Remove the setup frontmatter entirely if it is unused","Audit content collections for schema changes once files become .mdx"],"exampleFix":"# before  src/content/blog/post.md\n---\nsetup: |\n  import Banner from '../../components/Banner.astro';\n---\n<Banner />{/* rendered only with legacy .md component support */}\n\n# after  src/content/blog/post.mdx\nimport Banner from '../../components/Banner.astro';\n\n<Banner />","handlingStrategy":"validation","validationCode":"# CI gate: no legacy `setup` frontmatter left in markdown files\ngrep -rl --include='*.md' -E '^setup:' src/ && { echo 'migrate .md setup frontmatter to .mdx'; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt .mdx for any markdown that needs components or script","Codemod legacy content during major upgrades instead of keeping legacy behavior alive","Lint content-collection frontmatter keys via a schema"],"tags":["astro","markdown","mdx","migration","frontmatter"],"backgroundTag":"deprecated-feature-migration","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}