Skip to content

esbuild plugin for rendering markdown as React components

License

Notifications You must be signed in to change notification settings

zaydek/esbuild-mdx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esbuild-mdx

esbuild-mdx resolves .md and .mdx-delimited files as markdown components you can render in your React components.

  • Add dependencies:

    yarn add react react-dom
    yarn add --dev @mdx-js/react esbuild-mdx
  • Create esbuild.js:

    require("esbuild").build({
    	// ...
    	plugins: [require("esbuild-mdx")()],
    	// ...
    })
  • Create a .md or .mdx-delimited file:

    # Hello, world rendered by `esbuild-mdx`!
  • Import your .md or .mdx file and render as a React component:

    import React from "react"
    import ReactDOM from "react-dom"
    
    import MarkdownComponent from "./example.md"
    
    function App() {
    	return (
    		<div>
    			<h1>
    				Hello, world rendered by <code>React</code>!
    			</h1>
    			<MarkdownComponent />
    		</div>
    	)
    }
    
    ReactDOM.render(<App />, document.getElementById("root"))

See esbuild-mdx-example for a reference implementation.

Note: react, react-dom, and @mdx-js/react are peer dependencies.

License

Licensed as MIT open source.

About

esbuild plugin for rendering markdown as React components

Resources

License

Stars

Watchers

Forks

Packages

No packages published