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

Markdown relative image paths #3057

Closed
slorber opened this issue Jul 14, 2020 · 7 comments · Fixed by #3069
Closed

Markdown relative image paths #3057

slorber opened this issue Jul 14, 2020 · 7 comments · Fixed by #3069
Labels
bug An error in the Docusaurus core causing instability or issues with its execution mlh Major League Hacking Fellowship

Comments

@slorber
Copy link
Collaborator

slorber commented Jul 14, 2020

🐛 Bug Report

In /docs/myDoc.md

![text](./assets/image.png)

This should be able to display an image in "/docs/assets/image.png`


Potential solution:

  • MDX transpiles to <img src="./assets/image.png"/>
  • we should find a way to make it transpile to <img src={require("./assets/image.png").default}/>

Note, this kind of trick probably exist in Gatsby codebase, so it's worth taking a look

@slorber slorber added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers v2 and removed status: needs triage This issue has not been triaged by maintainers labels Jul 14, 2020
@anshulrgoyal
Copy link
Contributor

we can create a remark plugin for it and convert it to jsx before going to MDX.

@slorber slorber added the mlh Major League Hacking Fellowship label Jul 15, 2020
@slorber
Copy link
Collaborator Author

slorber commented Jul 15, 2020

yes if you can try to create a poc that would be cool :) I'm not very familiar with remark/rehype

@anshulrgoyal
Copy link
Contributor

ok i will create a POC.

@anshulrgoyal
Copy link
Contributor

I have created the poc but I need some help with webpack. I used url-loader in require to load image but it creates a wired base64 with export default embedded in base65 string

@anshulrgoyal
Copy link
Contributor

I fixed it and created a PR

@softmarshmallow
Copy link

softmarshmallow commented Dec 17, 2021

@anshulrgoyal So how do we use it? extra config required to support nested assets under docs dir?

@slorber
Copy link
Collaborator Author

slorber commented Dec 20, 2021

@softmarshmallow this feature is documented. For support, ask on Discord. Please clarify your question and show what you have tried in a sandbox/playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution mlh Major League Hacking Fellowship
Projects
None yet
3 participants