Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative image path ? #37

Open
belgattitude opened this issue Dec 21, 2018 · 3 comments
Open

relative image path ? #37

belgattitude opened this issue Dec 21, 2018 · 3 comments

Comments

@belgattitude
Copy link

Sorry I was not able to handle by myself...

Have a markdown containing an image tag:

![My image](./images/gravity-book-fr.jpg "My image")

I was assuming, the mdx-loader would resolve the picture from the markdown document file, and then let webpack do the regular job (take the picture, move it to the static dist, hash...) .

But it looks it's not the case... Is it something I can achieve (I mean with regular markdown, without import './img.jpg')

Have you any thoughts ? Thanks

@jamesknelson
Copy link
Collaborator

I'd really like to have support for this, but don't have time to implement it right now.

Would you be interested in doing this as a PR?

@belgattitude
Copy link
Author

Same time situation for me, but I would love too... Let's see.

@helfi92
Copy link
Contributor

helfi92 commented Dec 30, 2018

As a workaround, I am using the components prop to modify an img tag with a relative src to an absolute path:

imageFactory = ({ src, ...props }) => {
  const imgSrc = src.startsWith('http')
    ? src
    : <construct-absolute-url>

  return <img {...props} src={imgSrc} />;
};

// ...

<Document components={{ img: this.imageFactory }}

helfi92 added a commit to helfi92/taskcluster that referenced this issue Feb 22, 2019
This is because webpack was not picking up src images properly.
This should be no longer the case once
frontarm/mdx-util#37 is fixed.
helfi92 added a commit to helfi92/taskcluster that referenced this issue Feb 22, 2019
This is because webpack was not picking up src images properly.
This should be no longer the case once
frontarm/mdx-util#37 is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants