Core (Remark Image): Support relative import path

This commit is contained in:
fuma-nama
2024-08-13 19:51:25 +08:00
parent 5a8ef4d6e6
commit 36b771be99
3 changed files with 16 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
Remark Image: Support relative import path
@@ -91,6 +91,11 @@ export default {
Yields:
```mdx
<img alt="Hello" src"/hello.png" width="1980" height="1080" />
<img alt="Test" src"https://example.com/image.png" width="1980" height="1080" />
<img alt="Hello" src="/hello.png" width="1980" height="1080" />
<img
alt="Test"
src="https://example.com/image.png"
width="1980"
height="1080"
/>
```
@@ -107,7 +107,10 @@ export function remarkImage({
importsToInject.push({
variableName,
importPath: slash(resolveSrc(src, publicDir)),
importPath: slash(
// with imports, relative paths don't have to be absolute
src.startsWith('/') ? path.join(publicDir, src) : src,
),
});
Object.assign(node, {