Skip to content

Commit cc59bf5

Browse files
committed
Refactor image source handling in DocImage component to improve path resolution and add debug logging
1 parent 692cd8d commit cc59bf5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/docImage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function DocImage({
2424
// If the image src is not an absolute URL, we assume it's a relative path
2525
// and we prepend /mdx-images/ to it.
2626
if (src.startsWith('./')) {
27-
src = path.join('/mdx-images', src);
27+
src = '/mdx-images/' + src.slice(2); // Remove './' and prepend '/mdx-images/'
2828
}
2929
// account for the old way of doing things where the public folder structure mirrored the docs folder
3030
else if (!src?.startsWith('/') && !src?.includes('://')) {
@@ -34,6 +34,9 @@ export default function DocImage({
3434
// parse the size from the URL hash (set by remark-image-size.js)
3535
const srcURL = new URL(src, 'https://example.com');
3636
const imgPath = srcURL.pathname;
37+
38+
// Debug: log the final URL (remove this after testing)
39+
console.log('DocImage - Final src:', src, 'imgPath:', imgPath);
3740
const [width, height] = srcURL.hash // #wxh
3841
.slice(1)
3942
.split('x')

0 commit comments

Comments
 (0)