Description
Images in blog posts fail to load (404) because MarkdownRenderer computes a publicPath from window.location.pathname and prepends it to absolute image href values.
For a blog post at /blog/introducing-ocr-blog, the logic on line 81 of MarkdownRenderer.tsx:
const publicPath = (window.location.pathname.replace(/\/[^/]*$/, '') || '').replace(/\/$/, '');
// → "/blog"
Then on line 86:
const src = href.startsWith('/') ? `${publicPath}${href}` : href;
// href = "/images/blog/introducing-ocr-blog/demo.png"
// src = "/blog/images/blog/introducing-ocr-blog/demo.png" ← 404
The webpack config already sets publicPath: '/' (root deployment), so all absolute image paths (starting with /) should be used as-is without any prefix.
Expected behavior:  resolves to /images/blog/introducing-ocr-blog/demo.png.
Actual behavior: It resolves to /blog/images/blog/introducing-ocr-blog/demo.png (404).
Scope
- File:
pages/src/components/MarkdownRenderer.tsx
- Function:
renderer.image inside the html useMemo (lines 80–89)
- The fix is small: remove the
publicPath computation and use href directly as src for absolute paths.
Acceptance Criteria
Context
Discovered while viewing the introducing-ocr-blog post — the "Open Code Review 首页" demo image does not render. The publicPath logic was likely intended for sub-path deployments (e.g., GitHub Pages at /open-code-review/) but is incorrect for the current root-path deployment, and breaks on any page deeper than one level.
Description
Images in blog posts fail to load (404) because
MarkdownRenderercomputes apublicPathfromwindow.location.pathnameand prepends it to absolute imagehrefvalues.For a blog post at
/blog/introducing-ocr-blog, the logic on line 81 ofMarkdownRenderer.tsx:Then on line 86:
The webpack config already sets
publicPath: '/'(root deployment), so all absolute image paths (starting with/) should be used as-is without any prefix.Expected behavior:
resolves to/images/blog/introducing-ocr-blog/demo.png.Actual behavior: It resolves to
/blog/images/blog/introducing-ocr-blog/demo.png(404).Scope
pages/src/components/MarkdownRenderer.tsxrenderer.imageinside thehtmluseMemo (lines 80–89)publicPathcomputation and usehrefdirectly assrcfor absolute paths.Acceptance Criteria
/blog/introducing-ocr-blogshowsdemo.png)/docs/*)make check)Context
Discovered while viewing the
introducing-ocr-blogpost — the "Open Code Review 首页" demo image does not render. ThepublicPathlogic was likely intended for sub-path deployments (e.g., GitHub Pages at/open-code-review/) but is incorrect for the current root-path deployment, and breaks on any page deeper than one level.