Skip to content

Commit

Permalink
feat: support MDX v2 (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Dec 15, 2020
1 parent 8b57979 commit 5e2f2ce
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 65 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"dependencies": {
"@babel/runtime": "^7.12.5",
"fetch-retry": "^4.0.1",
"hast-util-from-parse5": "^6.0.1",
"node-fetch": "^2.6.1",
"parse5": "^6.0.1",
"unist-util-visit": "^2.0.3"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ describe('gatsby-remark-embedder', () => {
<iframe src="https://codepen.io/team/codepen/embed/preview/PNaGbb" style="width:100%; height:300px;"></iframe>
<iframe src="https://codesandbox.io/embed/ynn88nx9x?view=split" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>
<div style="width:100%;height:0;padding-bottom:63%;position:relative;"><iframe src="https://giphy.com/embed/XatG8bioEwwVO" width="100%" height="100%" style="position:absolute" frameborder="0" class="giphy-embed-from-cache" allowfullscreen></iframe></div>
<blockquote class="instagram-media-from-cache"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02T14:45:30+00:00">Jan 2, 2020 at 6:45am PST</time></p></div></blockquote>
<blockquote class="instagram-media-from-cache"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02t14:45:30+00:00">Jan 2, 2020 at 6:45am PST</timedatetime="2020-01-02t14:45:30+00:00"></p></div></blockquote>
<iframe src="https://lichess.org/embed/MPJcy1JW" width="600" height="397" frameborder="0"></iframe>
<a data-pin-do="embedPin" href="https://pinterest.com/pin/99360735500167749"></a>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src=https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa&color=ff5500&auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&show_teaser=false&visual=true></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa&#x26;color=ff5500&#x26;auto_play=false&#x26;hide_related=true&#x26;show_comments=true&#x26;show_user=true&#x26;show_reposts=false&#x26;show_teaser=false&#x26;visual=true"></iframe>
<iframe src="https://open.spotify.com/embed/track/0It2bnTdLl2vyymzOkBI3L" width="100%" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
<iframe class="streamable-embed-from-cache" src="https://streamable.com/o/moo" frameborder="0" scrolling="no" width="1920" height="1080" allowfullscreen></iframe>
<iframe src="https://testing-playground.com/embed/fb336c386145b235372a0f57d5c58205/6d13e4ee508301c8b42f9d2cc8584e70bb05fb4a?panes=query,preview" height="450" width="100%" scrolling="no" frameBorder="0" allowTransparency="true" style="overflow: hidden; display: block; width: 100%"></iframe>
<iframe src="https://player.twitch.tv?video=546761743&parent=embed.example.com" height="300" width="100%" frameborder="0" scrolling="no" allowfullscreen></iframe>
<blockquote class="twitter-tweet-from-cache"><p lang="en" dir="ltr">example</p>&mdash; Kent C. Dodds (@kentcdodds) <a href="https://twitter.com/kentcdodds/status/1078755736455278592">December 28, 2018</a></blockquote>
<iframe width="100%" height="315" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?rel=0" frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
<iframe src="https://testing-playground.com/embed/fb336c386145b235372a0f57d5c58205/6d13e4ee508301c8b42f9d2cc8584e70bb05fb4a?panes=query,preview" height="450" width="100%" scrolling="no" frameborder="0" allowtransparency="true" style="overflow: hidden; display: block; width: 100%"></iframe>
<iframe src="https://player.twitch.tv?video=546761743&#x26;parent=embed.example.com" height="300" width="100%" frameborder="0" scrolling="no" allowfullscreen></iframe>
<blockquote class="twitter-tweet-from-cache"><p lang="en" dir="ltr">example</p> Kent C. Dodds (@kentcdodds) <a href="https://twitter.com/kentcdodds/status/1078755736455278592">December 28, 2018</a></blockquote>
<iframe width="100%" height="315" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?rel=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
`);
});
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/transformers/Instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ test('Plugin can transform Instagram links', async () => {
<p><a href="https://instagram.com/MichaelDeBoey">https://instagram.com/MichaelDeBoey</a></p>
<p><a href="https://about.instagram.com">https://about.instagram.com</a></p>
<p><a href="https://help.instagram.com">https://help.instagram.com</a></p>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02T14:45:30+00:00">Jan 2, 2020 at 6:45am PST</time></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02T14:45:30+00:00">Jan 2, 2020 at 6:45am PST</time></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02T14:45:30+00:00">Jan 2, 2020 at 6:45am PST</time></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02T14:45:30+00:00">Jan 2, 2020 at 6:45am PST</time></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02t14:45:30+00:00">Jan 2, 2020 at 6:45am PST</timedatetime="2020-01-02t14:45:30+00:00"></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02t14:45:30+00:00">Jan 2, 2020 at 6:45am PST</timedatetime="2020-01-02t14:45:30+00:00"></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02t14:45:30+00:00">Jan 2, 2020 at 6:45am PST</timedatetime="2020-01-02t14:45:30+00:00"></p></div></blockquote>
<blockquote class="instagram-media-mocked-fetch-plugin"><div><a href="https://instagram.com/p/B60jPE6J8U-"><p>example</p></a><p>A post shared by <a href="https://instagram.com/michaeldeboey">Michaël De Boey</a> (@michaeldeboey) on<timedatetime="2020-01-02t14:45:30+00:00">Jan 2, 2020 at 6:45am PST</timedatetime="2020-01-02t14:45:30+00:00"></p></div></blockquote>
`);
});
4 changes: 2 additions & 2 deletions src/__tests__/transformers/Lichess.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ test('Plugin can transform Lichess links', async () => {
<p><a href="https://lichess.org/tv/best">https://lichess.org/tv/best</a></p>
<iframe src="https://lichess.org/embed/MPJcy1JW" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://www.lichess.org/embed/MPJcy1JW" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://lichess.org/embed/MPJcy1JW?theme=auto&bg=auto" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://www.lichess.org/embed/MPJcy1JW?theme=auto&bg=auto" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://lichess.org/embed/MPJcy1JW?theme=auto&#x26;bg=auto" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://www.lichess.org/embed/MPJcy1JW?theme=auto&#x26;bg=auto" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://lichess.org/embed/tv123abc56de" width="600" height="397" frameborder="0"></iframe>
<iframe src="https://www.lichess.org/embed/tv123abc56de" width="600" height="397" frameborder="0"></iframe>
Expand Down
36 changes: 18 additions & 18 deletions src/__tests__/transformers/Slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,24 @@ test('Plugin can transform Slides links', async () => {
<p><a href="https://slides.com/kentcdodds/oss-we-want/embed">https://slides.com/kentcdodds/oss-we-want/embed</a></p>
<p><a href="https://slides.com/kentcdodds/oss-we-want/fullscreen">https://slides.com/kentcdodds/oss-we-want/fullscreen</a></p>
<p><a href="https://slides.com/kentcdodds/oss-we-want/live">https://slides.com/kentcdodds/oss-we-want/live</a></p>
<iframe src="https://team.slides.com/hakimel/finch/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://acme.slides.com/jack-k/sales-template/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team-name.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team_name.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://asdfdsa11232889asd.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://ab.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/hakimel/finch/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/hakimel/finch/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/embed/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/fullscreen/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/live/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/embed/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/fullscreen/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/live/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://team.slides.com/hakimel/finch/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://acme.slides.com/jack-k/sales-template/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team-name.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team_name.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://asdfdsa11232889asd.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://ab.slides.com/username/deck-name/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team.slides.com/hakimel/finch/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team.slides.com/hakimel/finch/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/embed/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/fullscreen/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://team.slides.com/username/live/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/embed/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/fullscreen/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/michaeldeboey/live/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
<iframe src="https://slides.com/kentcdodds/oss-we-want/embed#/0" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen></iframe>
`);
});
4 changes: 2 additions & 2 deletions src/__tests__/transformers/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ test('Plugin can transform SoundCloud links', async () => {
<p><a href="https://api.soundcloud.com/tracks/151129490">https://api.soundcloud.com/tracks/151129490</a></p>
<p><a href="https://api.soundcloud.com/playlists/703823211">https://api.soundcloud.com/playlists/703823211</a></p>
<p><a href="https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa">https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa</a></p>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src=https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa&color=ff5500&auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&show_teaser=false&visual=true></iframe>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src=https://w.soundcloud.com/player?url=http://soundcloud.com/clemenswenners/africa&color=ff5500&auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&show_teaser=false&visual=true></iframe>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=https://soundcloud.com/clemenswenners/africa&#x26;color=ff5500&#x26;auto_play=false&#x26;hide_related=true&#x26;show_comments=true&#x26;show_user=true&#x26;show_reposts=false&#x26;show_teaser=false&#x26;visual=true"></iframe>
<iframe width="100%" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http://soundcloud.com/clemenswenners/africa&#x26;color=ff5500&#x26;auto_play=false&#x26;hide_related=true&#x26;show_comments=true&#x26;show_user=true&#x26;show_reposts=false&#x26;show_teaser=false&#x26;visual=true"></iframe>
`);
});

0 comments on commit 5e2f2ce

Please sign in to comment.