Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 1.26 KB

README.mdx

File metadata and controls

76 lines (48 loc) · 1.26 KB

import { name, description } from "../package.json"

{name}

{description}

Why?

This library is most useful for generating README.md files like the one you're reading.

Install

  yarn add {name}
  npm install {name}

CLI

mdx-to-md [sourcePath] [outPath]

In the simplest use case, you can run the CLI and it will output the converted Markdown relative to the current working directory the script was run in:

yarn mdx-to-md README.mdx

Node

Start with MDX:

import { name, description } from "./package.json"

# {name}

{description}

# Install

<pre>
  <code className="language-bash">yarn add {name}</code>
</pre>

And convert it to Markdown:

import { writeFile } from "fs/promises"
import { mdxToMd } from "mdx-to-md"

const markdown = await mdxToMd("README.mdx")
const banner = `This README was auto-generated using "yarn build:readme"`
const readme = `<!--- ${banner} --> \n\n ${markdown}`

await writeFile("README.md", readme)

console.log("📝 Converted README.mdx -> README.md")

Which outputs:

# mdx-to-md

Convert MDX to Markdown.

# Install

yarn add mdx-to-md