Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gatsby-remark-image #3620

Merged
merged 1 commit into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/gatsby-remark-images/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ test(`it leaves non-relative HTML img tags alone`, async () => {
`.trim()

const nodes = await plugin(createPluginOptions(content, imagePath))

expect(nodes.length).toBe(0)
expect(nodes[0].value).toBe(content)
})
16 changes: 9 additions & 7 deletions packages/gatsby-remark-images/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = (
}
return null
})

if (!imageNode || !imageNode.absolutePath) {
return resolve()
}
Expand Down Expand Up @@ -142,15 +143,16 @@ module.exports = (
) {
const rawHTML = await generateImagesAndUpdateNode(node, resolve)

if (rawHTML != null) {
if (rawHTML) {
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML
}
return resolve(node)
} else {
// Image isn't relative so there's nothing for us to do.
return resolve()
}

// Image isn't relative so there's nothing for us to do.
return resolve()
})
)
).then(markdownImageNodes =>
Expand Down Expand Up @@ -200,13 +202,13 @@ module.exports = (
resolve
)

if (rawHTML != null) {
if (rawHTML) {
// Replace the image string
thisImg.replaceWith(rawHTML)
} else {
return resolve()
}
}

return resolve()
}

// Replace the image node with an inline HTML node.
Expand Down