docusaurus/packages/docusaurus-mdx-loader
Sébastien Lorber a4329d3388
refactor(mdx-loader): read metadata from memory (loaded content) instead of fs (#10457)
* mdx loader shouldn't read metadata from file system but from memory

* comments

* refactor: apply lint autofix

* apply same for blog

* apply same for blog

* refactor: apply lint autofix

* apply same for pages
2024-08-30 08:02:26 +02:00
..
src refactor(mdx-loader): read metadata from memory (loaded content) instead of fs (#10457) 2024-08-30 08:02:26 +02:00
.npmignore misc: make copyUntypedFiles work for watch mode (#7445) 2022-05-18 19:18:32 +08:00
package.json chore: release 3.5.2 (#10400) 2024-08-13 14:47:19 +02:00
README.md docs: document siteConfig.markdown + better mdx-loader retrocompat (#8419) 2022-12-07 17:59:51 +01:00
tsconfig.json chore: simplify TypeScript configs, use TS 5.5 configDir placeholder (#10256) 2024-07-01 17:34:40 +02:00

@docusaurus/mdx-loader

Docusaurus webpack loader for MDX.

Installation

yarn add @docusaurus/mdx-loader

Usage

// ...
module: {
  rules: [
    // ...
    {
      test: /\.mdx?$/,
      use: [
        'babel-loader',
        {
          loader: '@docusaurus/mdx-loader',
          options: {
            // .. See options
          },
        },
      ],
    },
  ];
}

Options

rehypePlugins

Array of rehype plugins to manipulate the MDXHAST

remarkPlugins

Array of remark plugins to manipulate the MDXAST

metadataPath

A function to provide the metadataPath depending on current loaded MDX path that will be exported as the MDX metadata.

markdownConfig

The global Docusaurus Markdown config (config.markdown), that plugin authors should forward:

const loader = {
  loader: require.resolve('@docusaurus/mdx-loader'),
  options: {
    markdownConfig: siteConfig.markdown,
  },
};