jxnblk / mdx-go

:zap: Lightning fast MDX-based dev server for progressive documentation
https://mdx-go.now.sh
MIT License
364 stars 27 forks source link

Support Sub-Resources URLs for images #41

Open gwildu opened 2 years ago

gwildu commented 2 years ago

Would be great, if you could put images you'd like to refer to in an article right inside the folder where the file for the article is and then refer to it with a sub-resource URL as described here under "Relative URLs": https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL#examples_of_relative_urls

You already support such Routes for links to other articles, but not for images, so it would also be consistent.

File Structure:

- root
  - main
    - sub
      - index.mdx
      - image.png

image markdown:

![my image](image.png)
gwildu commented 2 years ago

Just figured out how that would work. The issue I had, was, that I was not putting the ending / in the link for that article: sub instead of sub/, which then of course was leading to the wrong base path for the sub-resource URL. Sorry for the disturbance.

gwildu commented 2 years ago

Sorry again, but now I figured out, that the trailing / in the link is by default stripped from the href attribute somewhere, so it would be great, if you could keep those trailing slashes so we could also use sub-resource urls for images or also deliver images the same way as you deliver articles because there it is not an issue when the trailing / is missing...

Link Markdown

[sub](sub/)

resulting HTML

<a href="sub/">sub</a>