๐ Patch Changes
- #7185
339529fc8Thanks @bholmesdev! - Bring back improved style and script handling across content collection files. This addresses bugs found in a previous release to@astrojs/markdoc.
339529fc8 Thanks @bholmesdev! - Bring back improved style and script handling across content collection files. This addresses bugs found in a previous release to @astrojs/markdoc.57e65d247 Thanks @bholmesdev! - Fix: revert Markdoc asset bleed changes. Production build issues were discovered that deserve a different fix.f558a9e20 Thanks @bholmesdev! - Improve style and script handling across content collection files. This addresses style bleed present in @astrojs/markdoc v0.1.02511d58d5 Thanks @Princesseuh! - Add support for using optimized and relative images in MDX files with experimental.assets2511d58d5]:
f882bc163 Thanks @bholmesdev! - Fix sourcemap warnings when using Content Collections and MDX with the vite.build.sourcemap option#6494 a13e9d7e3 Thanks @Yan-Thomas! - Consistency improvements to several package descriptions
Updated dependencies [a13e9d7e3]:
#6344 694918a56 Thanks @Princesseuh! - Add a new experimental flag (experimental.assets) to enable our new core Assets story.
This unlocks a few features:
See Assets (Experimental) on our docs site for more information on how to use this feature!
#6213 afbbc4d5b Thanks @Princesseuh! - Updated compilation settings to disable downlevelling for Node 14
#6209 fec583909 Thanks @bholmesdev! - Introduce the (experimental) @astrojs/markdoc integration. This unlocks Markdoc inside your Content Collections, bringing support for Astro and UI components in your content. This also improves Astro core internals to make Content Collections extensible to more file types in the future.
You can install this integration using the astro add command:
astro add markdocRead the @astrojs/markdoc documentation for usage instructions, and browse the new with-markdoc starter to try for yourself.
Updated dependencies [694918a56, afbbc4d5b]:
075b87e8b Thanks @RaphaelBossek! - Update to es-module-lexer@1.1.10049fda62 Thanks @bluwy! - Support rehype plugins that inject namespaced attributes. This introduces a breaking change if you use custom components for HTML elements, where the prop passed to the component will be normal HTML casing, e.g. class instead of className, and xlink:href instead of xlinkHref.#5684 a9c292026 Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use. & #5769 93e633922 Thanks @bholmesdev! - Introduce a smartypants flag to opt-out of Astroโs default SmartyPants plugin.
Markdown
extendDefaultPlugins option with a gfm boolean and a smartypants boolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants.remarkPlugins or rehypePlugins are configured. If you want to apply custom plugins and remove Astroโs default plugins, manually set gfm: false and smartypants: false in your config.Migrate extendDefaultPlugins to gfm and smartypants
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
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 includes syntaxHighlighting and shikiConfig options to further customize the MDX renderer.
Simplify extendPlugins 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.
Migrate MDXโs extendPlugins to extendMarkdownConfig
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 the extendPlugins: 'markdown' option.gfm (true by default) and smartypants (true by default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces the extendPlugins: 'defaults' option.#5687 e2019be6f 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:
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 includes getHeaders(), the .astro property for layouts, and the rawContent() and compiledContent() 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 experimental contentCollections flag. Youโre free to remove this from your astro config!
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { contentCollections: true }})