Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fedek6/rehype-img-src
https://github.com/fedek6/rehype-img-src
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fedek6/rehype-img-src
- Owner: fedek6
- Created: 2022-08-08T19:23:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-09T20:09:04.000Z (over 2 years ago)
- Last Synced: 2024-08-10T00:04:59.354Z (3 months ago)
- Language: TypeScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rehype-img-src
Rehype plugin for `next-mdx-remote`. By using it you can rewrite image src to whatever you like.
## Example
* `dir` is used for a server path.
* `url` is used for public url.```ts
const source = await serialize(file.content, {
mdxOptions: {
// use the image size plugin, you can also specify which folder to load images from
// in my case images are in /public/images/, so I just prepend 'public'rehypePlugins: [
[
setImageSrc,
{
dir: "public/images/hello-world-3/",
url: "/images/hello-world-3/",
},
],
],
},
});
```This way you can use:
```mdx
![my image](./test.jpg)
```And copy assets to `/public` of a `Next.js` instance.
*More docs soon...*