LeaVerou / md-block

A custom element for rendering stylable (light DOM) Markdown
https://md-block.verou.me
MIT License
322 stars 17 forks source link

external md file not loading #13

Closed uinguzero closed 1 year ago

uinguzero commented 1 year ago

With just a simple md-block from the demo, everything works,

but when i try to load an external md file using

  <script type="module" src="https://md-block.verou.me/md-block.js"></script>
<md-block src="output.md">
    `output.md` was *not* found
</md-block>

with output.md on the smae level as my htm file it always shows output.md was not found I've also tried ./output.md or the full path /home/user/tmp/output.md

LeaVerou commented 1 year ago

How are you running the page? What URL from? What's the file structure? Thanks!

uinguzero commented 1 year ago

It is just a standalone html page, which i run in brave, but tested in other browsers as well, like firefox.

code: https://pastebin.com/zCLrPSyX

If i copy the content of my output.md file inside the block, it works perfectly, but it does not import it like the code above

uinguzero commented 1 year ago

@LeaVerou any news? I've tried the demo on the website, and there it works, but when i just put the same code in an stand alone htm file that is running locally on my computer, it doesn't work.

LeaVerou commented 1 year ago

md-block uses fetch() behind the scenes, and I can't remember if that's one of the APIs that don't work under file:// (the protocol used when you just open an HTML file with a browser). Try using a local server (localhost) and I think it will solve the problem. In general you'll find more and more things don't work under file://, it's considered unsafe, so browsers are not running many newer APIs on that.

uinguzero commented 1 year ago

@LeaVerou you are correct. When running the page through a local webserver it displays the content of a sourced MD file correctly

uinguzero commented 1 year ago

When running the page through a local webserver it displays the content of a sourced MD file correctly