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

"copyfiles" block allows documents to request files to copy #5

Closed dansanderson closed 4 years ago

dansanderson commented 4 years ago

This adds a feature where a Remark document can request additional files to be copied without linking to them directly. This is useful when a Remark document links to a resource that depends on other resources, such as to an HTML file. To do this, the document declares a "copyfiles" code fence:

    See [this generated report](report.html) for more information.

    ```copyfiles
    report.css
    diagram.png

This is option 3 discussed in feature request issue #4.

Tested with:

```bash
gatsby new test-md-blog https://github.com/gatsbyjs/gatsby-starter-blog
cd test-md-blog
npm install --save dansanderson/npm-gatsby-remark-copy-relative-linked-files

Edited gatsby-config.js to replace gatsby-remark-copy-linked-files with gatsby-remark-copy-relative-linked-files and reordered the plugins so this one comes before prismjs. Then set up an example similar to the above in the hello-world blog entry, gatsby build, gatsby serve. Confirmed that the example works.

Feel free to reject if you don't like this design. This fork works for me. :) Thanks!

akabekobeko commented 4 years ago

@dansanderson Thank you!! There was no problem as a function, and tests and comments were maintained, so they were merged.