#576993e633922 Thanks @bholmesdev! - Introduce a smartypants flag to opt-out of Astro’s default SmartyPants plugin.
{
markdown: {
smartypants: false,
}
}
Migration
You may have disabled Astro’s built-in plugins (GitHub-Flavored Markdown and Smartypants) with the extendDefaultPlugins option. This has now been split into 2 flags to disable each plugin individually:
#5687e2019be6f Thanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means data.astro.frontmatter is now the complete Markdown or MDX document’s frontmatter, rather than an empty object.
This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an imageSrc slug in your document frontmatter:
Content Collections - new remarkPluginFrontmatter property
We have changed inject frontmatter to modify frontmatter in our docs to improve discoverability. This is based on support forum feedback, where “injection” is rarely the term used.
To reflect this, the injectedFrontmatter property has been renamed to remarkPluginFrontmatter. This should clarify this plugin is still separate from the data export Content Collections expose today.
Migration instructions
Plugin authors should now check for user frontmatter when applying defaults.
For example, say a remark plugin wants to apply a default title if none is present. Add a conditional to check if the property is present, and update if none exists:
export function remarkInjectTitlePlugin() {
return function (tree, file) {
const { frontmatter } = file.data.astro;
if (!frontmatter.title) {
frontmatter.title = 'Default title';
}
}
}
This differs from previous behavior, where a Markdown file’s frontmatter would always override frontmatter injected via remark or reype.
Remove remark-smartypants from Astro’s default Markdown plugins.
Replace the extendDefaultPlugins option with a simplified gfm boolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown.
Ensure GitHub-Flavored Markdown is applied whether or not custom remarkPlugins or rehypePlugins are configured. If you want to apply custom plugins and remove GFM, manually set gfm: false in your config.
MDX
Support all Markdown configuration options (except drafts) from your MDX integration config. This includes syntaxHighlighting and shikiConfig options to further customize the MDX renderer.
Simplify extendDefaults to an extendMarkdownConfig option. MDX options will default to their equivalent in your Markdown config. By setting extendMarkdownConfig to false, you can “eject” to set your own syntax highlighting, plugins, and more.
Migration
To preserve your existing Markdown and MDX setup, you may need some configuration changes:
You may have disabled Astro’s built-in plugins (GitHub-Flavored Markdown and Smartypants) with the extendDefaultPlugins option. Since Smartypants has been removed, this has been renamed to gfm.
astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
markdown: {
extendDefaultPlugins: false,
gfm: false,
}
});
Additionally, applying remark and rehype plugins no longer disablesgfm. You will need to opt-out manually by setting gfm to false.
Migrate MDX’s extendPlugins to extendMarkdownConfig
You may have used the extendPlugins option to manage plugin defaults in MDX. This has been replaced by 2 flags:
extendMarkdownConfig (true by default) to toggle Markdown config inheritance. This replaces the extendPlugins: 'markdown' option.
gfm (true by default) to toggle GitHub-Flavored Markdown in MDX. This replaces the extendPlugins: 'defaults' option.
#5335dca762cf7 Thanks @bluwy! - Preserve code element node data.meta in properties.metastring for rehype syntax highlighters, like `rehype-pretty-code``
#45048f8dff4d3 Thanks @bholmesdev! - Introduce new extendPlugins configuration option. This defaults to inheriting all remark and rehype plugins from your markdown config, with options to use either Astro’s defaults or no inheritance at all.
#4423d4cd7a59f Thanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment
#4423d4cd7a59f Thanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment