Skip to content

Commit 19c6b86

Browse files
committed
Merge branch 'develop'
2 parents 7690801 + abb3e64 commit 19c6b86

File tree

5 files changed

+95
-38
lines changed

5 files changed

+95
-38
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ typings/
6060
# next.js build output
6161
.next
6262

63-
/*.js
63+
index.js
6464
!babel.config.js
6565
package-lock.json

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v1.1.0
4+
5+
### Features
6+
7+
- Copy video and audio from HTML and JSX [#8](https://github.com/akabekobeko/npm-gatsby-remark-copy-relative-linked-files/pull/8) by [karlhorky](https://github.com/karlhorky)
8+
39
## v1.0.3
410

511
### Features

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,55 @@ plugins: [
2323
{
2424
resolve: 'gatsby-transformer-remark',
2525
options: {
26-
plugins: ['gatsby-remark-copy-relative-linked-files']
27-
}
28-
}
26+
plugins: ['gatsby-remark-copy-relative-linked-files'],
27+
},
28+
},
2929
]
3030
```
3131

32-
*Note:* When using the `copyfiles` code fence (see below), `gatsby-remark-copy-relative-linked-files` must appear before general purpose code fence processors like `gatsby-remark-prismjs`.
32+
_Note:_ When using the `copyfiles` code fence (see below), `gatsby-remark-copy-relative-linked-files` must appear before general purpose code fence processors like `gatsby-remark-prismjs`.
3333

3434
Then in your Markdown files, simply reference the files.
3535

3636
### E.g.
3737

38-
```markdown
39-
---
40-
title: My awesome blog post
41-
---
38+
````markdown
39+
---
40+
title: My awesome blog post
41+
---
4242

43-
Hey everyone, I just made a sweet files with lots of interesting stuff in
44-
it.
43+
Hey everyone, I just made a sweet files withlots of interesting stuff in
44+
it.
4545

46-
- ![](image.gif)
47-
- [archive.zip](archive.zip)
48-
- [sample.pdf](sample.pdf)
49-
- [report.html](report.html)
50-
- [not-copy.rar](https://example.com/not-copy.rar)
46+
- ![](image.gif)
47+
- [archive.zip](archive.zip)
48+
- [sample.pdf](sample.pdf)
49+
- [report.html](report.html)
50+
- [not-copy.rar](https://example.com/not-copyrar)
5151

52-
```copyfiles
53-
report.css
54-
diagram.png
55-
```
52+
```copyfiles
53+
report.css
54+
diagram.png
5655
```
5756

57+
<audio src="sample.mp3" controls></audio>
58+
<video src="sample.mp4" controls></video>
59+
<video controls>
60+
61+
<source src="sample2.mp4" type="video/mp4">
62+
</video>
63+
````
64+
5865
`image.gif`, `archive.zip`, `sample.pdf` and `report.html` should be in the same directory as the Markdown file. When you build your site, the file will be copied to the public folder and the markdown HTML will be modified to point to it.
5966

6067
Similarly, `report.css` and `diagram.png` should be in the same directory as the Markdown file. In this example, `report.html` has its own internal relative links to these files. `report.html` is not changed in any way. The relative links to the copied files work from the copied location.
6168

6269
The copy target is a relative link. Therefore, links starting with `XXXX://` or `//` are ignored. In this example `not-copy.rar` is not copied.
6370

71+
**v1.1.0**
72+
73+
[Pull request](https://github.com/akabekobeko/npm-gatsby-remark-copy-relative-linked-files/pull/8) by [karlhorky](https://github.com/karlhorky) also copied the `src` attribute of `<audio>`/`<video>`/`<source>` tag.
74+
6475
## Options
6576

6677
```js
@@ -77,12 +88,12 @@ plugins: [
7788
// ignoreFileExtensions: ['.md']
7889

7990
// These files will not be copied
80-
ignoreFileExtensions: ['.md', '.pdf', '.d.ts']
81-
}
82-
}
83-
]
84-
}
85-
}
91+
ignoreFileExtensions: ['.md', '.pdf', '.d.ts'],
92+
},
93+
},
94+
],
95+
},
96+
},
8697
]
8798
```
8899

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gatsby-remark-copy-relative-linked-files",
33
"description": "Copies local files relative linked to/from markdown to your public folder with preserve directory structure.",
4-
"version": "1.0.3",
4+
"version": "1.1.0",
55
"author": "akabeko (http://akabeko.me/)",
66
"license": "MIT",
77
"homepage": "https://github.com/akabekobeko/npm-gatsby-remark-copy-relative-linked-files#readme",
@@ -32,17 +32,17 @@
3232
"watch": "babel -w src --out-dir . --ignore **/*.test.js"
3333
},
3434
"dependencies": {
35-
"fs-extra": "^7.0.1",
36-
"htmlparser2": "^4.1.0",
37-
"unist-util-visit": "^1.4.0"
35+
"fs-extra": "^9.0.1",
36+
"htmlparser2": "^5.0.0",
37+
"unist-util-visit": "^2.0.3"
3838
},
3939
"devDependencies": {
40-
"@babel/cli": "^7.4.3",
41-
"@babel/core": "^7.4.3",
42-
"@babel/preset-env": "^7.4.3",
43-
"cross-env": "^5.2.0",
44-
"jest": "^24.7.1",
45-
"remark": "^10.0.1",
46-
"rewire": "^4.0.1"
40+
"@babel/cli": "^7.11.6",
41+
"@babel/core": "^7.11.6",
42+
"@babel/preset-env": "^7.11.5",
43+
"cross-env": "^7.0.2",
44+
"jest": "^26.5.2",
45+
"remark": "^12.0.1",
46+
"rewire": "^5.0.0"
4747
}
4848
}

src/index.test.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,47 @@ describe('gatsby-remark-copy-relative-linked-files', () => {
241241
})
242242
})
243243

244+
describe('HTML', () => {
245+
test('<video>', async () => {
246+
const file = 'sample.mp4'
247+
const markdownAST = remark.parse(`<video src="${file}"></video>`)
248+
await Plugin({
249+
files: getFiles(file),
250+
markdownAST,
251+
markdownNode,
252+
getNode
253+
})
254+
255+
expect(FsExtra.copy).toHaveBeenCalled()
256+
})
257+
258+
test('<source>', async () => {
259+
const file = 'sample.mp4'
260+
const markdownAST = remark.parse(`<video><source src='sample.mp4' type="video/mp4"></video>`)
261+
await Plugin({
262+
files: getFiles(file),
263+
markdownAST,
264+
markdownNode,
265+
getNode
266+
})
267+
268+
expect(FsExtra.copy).toHaveBeenCalled()
269+
})
270+
271+
test('<audio>', async () => {
272+
const file = 'sample.mp3'
273+
const markdownAST = remark.parse(`<audio src="${file}"></video>`)
274+
await Plugin({
275+
files: getFiles(file),
276+
markdownAST,
277+
markdownNode,
278+
getNode
279+
})
280+
281+
expect(FsExtra.copy).toHaveBeenCalled()
282+
})
283+
})
284+
244285
describe('manifest', () => {
245286
test('One file', async () => {
246287
const path = 'sample.thumb.jpg'
@@ -316,7 +357,6 @@ describe('gatsby-remark-copy-relative-linked-files', () => {
316357
const isIgnore = Module.__get__('isIgnore')
317358

318359
test('Not igonre', () => {
319-
const extensions = ['.pdf']
320360
expect(isIgnore('sample.pdf')).toBeFalsy()
321361
})
322362

0 commit comments

Comments
 (0)