Socket
Socket
Sign inDemoInstall

@mdx-js/mdx

Package Overview
Dependencies
Maintainers
4
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mdx-js/mdx

Parse MDX and transpile to JSX


Version published
Weekly downloads
2.2M
decreased by-12.64%
Maintainers
4
Weekly downloads
 
Created

What is @mdx-js/mdx?

The @mdx-js/mdx package is a Markdown processor powered by JSX and React. It allows you to write JSX in your Markdown documents and render them as React components. This enables the embedding of dynamic content within static Markdown files, combining the simplicity of Markdown with the power of React.

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

Writing JSX in Markdown

Allows embedding JSX directly in your Markdown files, which can then be transformed into React components.

import React from 'react'
import { MDXProvider } from '@mdx-js/react'
import { mdx } from '@mdx-js/mdx'

const mdxContent = `
# Hello, MDX!

Some **bold** text and a component:

<MyComponent />
`

const MyComponent = () => <div>My Custom Component</div>

const run = async () => {
  const jsx = await mdx(mdxContent)
  // Now you can render the jsx with your preferred method
}

run()

Customizing Markdown components

Enables overriding default HTML tags with custom React components for a more personalized rendering of Markdown content.

import React from 'react'
import { MDXProvider } from '@mdx-js/react'

const components = {
  h1: props => <h1 style={{ color: 'tomato' }} {...props} />,
  p: props => <p style={{ fontSize: '18px' }} {...props} />
}

const MarkdownContent = () => (
  <MDXProvider components={components}>
    <YourMDXContent />
  </MDXProvider>
)

Using MDX files as pages in a React application

Facilitates the use of MDX files as if they were React components, making it easy to integrate them into a React application as pages or parts of pages.

import React from 'react'
import { MDXProvider } from '@mdx-js/react'
import YourMDXPage from './YourMDXPage.mdx'

const App = () => (
  <MDXProvider>
    <YourMDXPage />
  </MDXProvider>
)

Other packages similar to @mdx-js/mdx

Keywords

FAQs

Package last updated on 01 May 2020

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