github withastro/astro @astrojs/mdx@0.15.0

latest releases: astro@4.15.11, @astrojs/sitemap@3.2.0, astro@5.0.0-beta.3...
20 months ago

Minor Changes

  • #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

      • Replace the 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.
      • Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom 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

        // 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 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 }
    })

Patch Changes

Don't miss a new astro release

NewReleases is sending notifications on new releases.