0.3.2 • Published 3 months ago

parcel-transformer-mdx v0.3.2

Weekly downloads
-
License
LGPL-3.0-or-later
Repository
-
Last release
3 months ago

Parcel MDX transformer

Unofficial MDX 3 transformer plugin for Parcel 2

NPM Dependency CI & CD

Supported features

  1. GitHub flavored Markdown (GFM)
  2. Frontmatter
  3. Syntax highlighting
  4. Embed

React usage

Installation

npm init -y
npm i react react-dom
npm i parcel @parcel/config-default parcel-transformer-mdx -D

package.json

{
    "scripts": {
        "start": "parcel ./src/index.html",
        "build": "parcel build ./src/index.html --public-url ."
    }
}

.parcelrc

{
    "extends": "@parcel/config-default",
    "transformers": {
        "*.{md,mdx}": ["parcel-transformer-mdx"]
    }
}

index.html

<!doctype html>
<html>
    <head>
        <link
            rel="stylesheet"
            href="https://unpkg.com/prismjs@1.29.0/themes/prism-okaidia.css"
        />
    </head>
    <body>
        <div id="root"></div>

        <script type="module" src="index.jsx"></script>
    </body>
</html>

index.jsx

import { createRoot } from 'react-dom/client';

import Index from './index.mdx';

const root = createRoot(document.querySelector('#root'));

root.render(<Index />);

index.mdx

---
title: Hello MDX
---

# Hello MDX

https://react.dev/

https://www.youtube.com/watch?v=VEoMT8pAxMA

JSX compatible engines usage

Inspiration

https://github.com/parcel-bundler/parcel/pull/7922