akabekobeko / npm-gatsby-remark-copy-relative-linked-files

Copies local files relative linked to/from markdown to your public folder with preserve directory structure.
MIT License
6 stars 3 forks source link

Copying videos, audio files, and other content referenced from HTML in Markdown? #7

Closed karlhorky closed 4 years ago

karlhorky commented 4 years ago

Hi there, first of all, thanks so much for this plugin! It's so much nicer to have the full path to the file.

I am using this with some video files embedded like this:

<video src="003-resize-codesandbox-console.mp4" />

Would it be possible to gather these file paths and copy them as well?

Also, maybe alternative syntaxes (and audio? and maybe other types of files?):

<video controls="controls">
  <source type="video/mp4" src="filename.mp4"></source>
  <source type="video/mp4" src="filename.webm"></source>
</video>

<audio controls="controls">
  <source type="audio/mp3" src="filename.mp3"></source>
</audio>
akabekobeko commented 4 years ago

@karlhorky

Currently, only those that are linked as Markdown are copied.

However, if you can use remark to handle audio andvideo tags, you may want to target them as well. In that case, you should also consider <img> written in HTML.

Think about the policy.

akabekobeko commented 4 years ago

If it corresponds, it seems to be an element containing the src attribute. e.g. <img>, <video>, <audio>

akabekobeko commented 4 years ago

It seems better to support <a> within own site.

karlhorky commented 4 years ago

However, if you can use remark to handle audio andvideo tags, you may want to target them as well

@akabekobeko Ok, I took a look at parsing the HTML / JSX and came up with this solution, which I have tested to work:

https://github.com/akabekobeko/npm-gatsby-remark-copy-relative-linked-files/pull/8

What are your thoughts? If you're happy with this direction, I can add whatever is needed to get this accepted.