Skip to content

Commit

Permalink
Add “When should I use this” section to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Mar 29, 2024
1 parent 3d402ea commit 6227bb9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ paths into imports.
## Table of Contents

- [Installation](#installation)
- [When should I use this?](#when-should-i-use-this)
- [Usage](#usage)
- [Example](#example)
- [API](#api)
- [Options](#options)
- [Compatibility](#compatibility)
Expand All @@ -23,6 +25,21 @@ paths into imports.
npm install rehype-mdx-import-media
```

## When should I use this?

You may want to author images in MDX using the markdown format, like so:

```markdown
![alt](./image.png 'title')
```

You may use MDX with a bundler such as [Webpack](https://webpack.js.org) or
[Vite](http://vitejs.dev). By default bundlers don’t understand how to resolve those images. They
only understand how to resolve imports. This plugin solves that problem.

Also you may use MDX to load markdown files. If you reference other media in those markdown files
using HTML tags, that media can be resolved by this plugin too.

## Usage

This plugin takes HTML elements that refer to media content, and turns them into MDX expressions
Expand All @@ -41,7 +58,9 @@ nodes into an
This may prevent other rehype plugins from further processing. To avoid this, put
`rehype-mdx-import-media` after any other rehype plugins

For example, given a file named `example.mdx` with the following contents:
## Example

Let’s say we have a file named `example.mdx` with the following contents:

```mdx
![](./image.png)
Expand Down

0 comments on commit 6227bb9

Please sign in to comment.