Minor Changes
-
#5684
a9c292026
Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use. & #576993e633922
Thanks @bholmesdev! - Introduce asmartypants
flag to opt-out of Astro's default SmartyPants plugin.-
Markdown
- Replace the
extendDefaultPlugins
option with agfm
boolean and asmartypants
boolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants. - Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom
remarkPlugins
orrehypePlugins
are configured. If you want to apply custom plugins and remove Astro's default plugins, manually setgfm: false
andsmartypants: false
in your config.
- Replace the
-
Migrate
extendDefaultPlugins
togfm
andsmartypants
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:-
markdown.gfm
to disable GitHub-Flavored Markdown -
markdown.smartypants
to disable SmartyPants// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: {
-
extendDefaultPlugins: false,
-
smartypants: false,
-
gfm: false,
}
});Additionally, applying remark and rehype plugins **no longer disables** `gfm` and `smartypants`. You will need to opt-out manually by setting `gfm` and `smartypants` to `false`.
-
-
MDX
-
Support all Markdown configuration options (except
drafts
) from your MDX integration config. This includessyntaxHighlighting
andshikiConfig
options to further customize the MDX renderer. -
Simplify
extendPlugins
to anextendMarkdownConfig
option. MDX options will default to their equivalent in your Markdown config. By settingextendMarkdownConfig
to false, you can "eject" to set your own syntax highlighting, plugins, and more.
-
-
Migrate MDX's
extendPlugins
toextendMarkdownConfig
You may have used the
extendPlugins
option to manage plugin defaults in MDX. This has been replaced by 3 flags:extendMarkdownConfig
(true
by default) to toggle Markdown config inheritance. This replaces theextendPlugins: 'markdown'
option.gfm
(true
by default) andsmartypants
(true
by default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces theextendPlugins: 'defaults'
option.
-
-
#5687
e2019be6f
Thanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This meansdata.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:export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; }
When using Content Collections, you can access this modified frontmatter using the
remarkPluginFrontmatter
property returned when rendering an entry.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.
-
#5891
05caf445d
Thanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includesgetHeaders()
, the.astro
property for layouts, and therawContent()
andcompiledContent()
error messages for MDX. -
#5782
1f92d64ea
Thanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -
#5825
52209ca2a
Thanks @bholmesdev! - Baseline the experimentalcontentCollections
flag. You're free to remove this from your astro config!import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } })