Bug: Error displaying images in posts
vi8pro opened this issue · 4 comments
vi8pro commented
QuantGeekDev commented
I think it's due to the client-side routing. The same happens with gifs - which I addressed in my media optimizatoin pull request #826 but it still happens with images embedded through markdown
hungvu946 commented
Let's go to overreacted.io, turn on debugger (F12 chrome > Network), and click post Algebraic Effects for the Rest of Us
And observing through the debugger, every time the page is loaded it will load 2 images:
- https://overreacted.io/effects.jpg - 404
- https://overreacted.io/algebraic-effects-for-the-rest-of-us/effects.jpg
I can't find why it loads the first url resulting in a 404 error. Any ideas?
hungvu946 commented
I have found the solution. Need to handle adding the article slug to the img's src
in page.js, add img to MDXRemote:
img: (props) => {
if (props.src) {
props.src = `/${params.slug}/${props.src}`;
}
return <img {...props} />;
},
QuantGeekDev commented
@hungvu946
Smart, are you going to PR it or should I add it?