Socket
Socket
Sign inDemoInstall

@mdx-js/loader

Package Overview
Dependencies
Maintainers
3
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mdx-js/loader

Loader for MDX


Version published
Weekly downloads
601K
decreased by-9.53%
Maintainers
3
Weekly downloads
 
Created

What is @mdx-js/loader?

@mdx-js/loader is a webpack loader for MDX, which allows you to import and use .mdx files as React components. MDX is a format that lets you seamlessly write JSX in your Markdown documents. This package is particularly useful for integrating MDX into your React projects, enabling you to leverage the power of React components within your Markdown content.

What are @mdx-js/loader's main functionalities?

Importing MDX files as React components

This feature allows you to import MDX files as React components, enabling you to use JSX syntax within your Markdown files. The code sample demonstrates how to configure webpack to use @mdx-js/loader and how to use an MDX file within a React component.

```javascript
// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.mdx?$/,
        use: [
          'babel-loader',
          '@mdx-js/loader'
        ]
      }
    ]
  }
};

// example.mdx
export const MyComponent = () => <div>Hello, MDX!</div>;

# Hello, world!

<MyComponent />

// App.js
import React from 'react';
import MDXContent from './example.mdx';

const App = () => (
  <div>
    <MDXContent />
  </div>
);

export default App;
```

Customizing MDX components

This feature allows you to customize MDX components by importing and using your own React components within MDX files. The code sample shows how to import a custom React component into an MDX file and use it within the Markdown content.

```javascript
// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.mdx?$/,
        use: [
          'babel-loader',
          '@mdx-js/loader'
        ]
      }
    ]
  }
};

// example.mdx
import { MyCustomComponent } from './MyCustomComponent';

# Hello, world!

<MyCustomComponent />

// MyCustomComponent.js
import React from 'react';

export const MyCustomComponent = () => <div>Custom Component Content</div>;

// App.js
import React from 'react';
import MDXContent from './example.mdx';

const App = () => (
  <div>
    <MDXContent />
  </div>
);

export default App;
```

Other packages similar to @mdx-js/loader

Keywords

FAQs

Package last updated on 03 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc