Skip to content

Commit 0e064ba

Browse files
authored
fix: Handle links without children properly (#86)
* 🐛 Fix bug that prevents childMarkdownRemark from being set * Updates after code review
1 parent c82a8bb commit 0e064ba

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/__tests__/__fixtures__/kitchensink.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This is a paragraph with a [link](https://example.com).
1515

1616
<https://example.com>
1717

18+
[](https://example.com)
19+
1820
https://codepen.io/team/codepen/pen/PNaGbb
1921

2022
https://codesandbox.io/s/ynn88nx9x?view=split

src/__tests__/plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ describe('gatsby-remark-embedder', () => {
4141
4242
<https://example.com>
4343
44+
[](https://example.com)
45+
4446
<iframe src=\\"https://codepen.io/team/codepen/embed/preview/PNaGbb\\" style=\\"width:100%; height:300px;\\"></iframe>
4547
4648
<iframe src=\\"https://codesandbox.io/embed/ynn88nx9x?view=split\\" style=\\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\\" allow=\\"geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb\\" sandbox=\\"allow-modals allow-forms allow-popups allow-scripts allow-same-origin\\"></iframe>

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default async (
3131
const isValidLink =
3232
node.type === 'link' &&
3333
node.title === null &&
34+
node.children.length === 1 &&
3435
node.children[0].value === node.url;
3536
if (!isText && !isValidLink) {
3637
return;

0 commit comments

Comments
 (0)