File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -222,13 +222,16 @@ const mdxComponents = {
222222 : parseInt ( props . height ) || defaultHeight
223223 : defaultHeight ;
224224
225- let url = props . src ;
226-
227- // Add base path for local public images if needed
228- // If url starts with / and not //, prepend base path if in production mode
229- // But we don't have access to runtime config easily here.
230- // Ideally, use Next.js Image which handles basePath automatically.
231-
225+ // Prepend NEXT_PUBLIC_BASE_PATH for local public images (src starts with /).
226+ // Next.js does NOT automatically prepend basePath to plain <img> or ImageZoom src strings —
227+ // only its own <Image> component gets that treatment. Since fetch-docs writes
228+ // <img src="/filaletter/..." /> with absolute paths, we must add the prefix here.
229+ const basePath = process . env . NEXT_PUBLIC_BASE_PATH || "" ;
230+ let url : string =
231+ typeof src === "string" && src . startsWith ( "/" ) && ! src . startsWith ( "//" )
232+ ? basePath + src
233+ : ( src as string ) ;
234+
232235 return (
233236 < ImageZoom
234237 src = { url }
You can’t perform that action at this time.
0 commit comments