From 00c7a01524e33c9a96c960b68ef18fc561b24706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 19 Jan 2018 19:14:19 +0100 Subject: [PATCH 1/5] Fix images disappearing from rendered markdown files Fixes #3608 --- packages/gatsby-remark-images/src/index.js | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/gatsby-remark-images/src/index.js b/packages/gatsby-remark-images/src/index.js index 2384553001b01..af68e330876b6 100644 --- a/packages/gatsby-remark-images/src/index.js +++ b/packages/gatsby-remark-images/src/index.js @@ -85,19 +85,19 @@ module.exports = ( class="gatsby-resp-image-wrapper" style="position: relative; display: block; ${ options.wrapperStyle - }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" + }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" > ${node.alt ? node.alt : defaultAlt} @@ -197,11 +199,14 @@ module.exports = ( formattedImgTag, resolve ) - // Replace the image string - thisImg.replaceWith(rawHTML) - } else { - return resolve() + + if (rawHTML != null) { + // Replace the image string + thisImg.replaceWith(rawHTML) + } } + + return resolve() } // Replace the image node with an inline HTML node. @@ -213,6 +218,6 @@ module.exports = ( ) ).then(htmlImageNodes => markdownImageNodes.concat(htmlImageNodes).filter(node => !!node) + ) ) - ) } From c332a76124ae17b71224681940af37bca24e53c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 19 Jan 2018 19:23:19 +0100 Subject: [PATCH 2/5] Revert invalid indentation changes --- packages/gatsby-remark-images/src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-remark-images/src/index.js b/packages/gatsby-remark-images/src/index.js index af68e330876b6..3dfe2dceee606 100644 --- a/packages/gatsby-remark-images/src/index.js +++ b/packages/gatsby-remark-images/src/index.js @@ -85,19 +85,19 @@ module.exports = ( class="gatsby-resp-image-wrapper" style="position: relative; display: block; ${ options.wrapperStyle - }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" + }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" > ${node.alt ? node.alt : defaultAlt} markdownImageNodes.concat(htmlImageNodes).filter(node => !!node) - ) ) + ) } From 5d11526de24e8b2668b9f7ff38ffd3a0e0a9501b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sat, 20 Jan 2018 13:11:37 +0100 Subject: [PATCH 3/5] Fix copying "dev-404-page.js" to the cache folder on Windows Fixes #2819 --- packages/gatsby/src/bootstrap/load-plugins.js | 6 +++--- .../gatsby/src/internal-plugins/dev-404-page/gatsby-node.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gatsby/src/bootstrap/load-plugins.js b/packages/gatsby/src/bootstrap/load-plugins.js index b0ba05cbf0681..47331eef13114 100644 --- a/packages/gatsby/src/bootstrap/load-plugins.js +++ b/packages/gatsby/src/bootstrap/load-plugins.js @@ -133,6 +133,9 @@ module.exports = async (config = {}) => { } // Add internal plugins + plugins.push( + processPlugin(path.join(__dirname, `../internal-plugins/dev-404-page`)) + ) plugins.push( processPlugin( path.join(__dirname, `../internal-plugins/component-page-creator`) @@ -148,9 +151,6 @@ module.exports = async (config = {}) => { path.join(__dirname, `../internal-plugins/internal-data-bridge`) ) ) - plugins.push( - processPlugin(path.join(__dirname, `../internal-plugins/dev-404-page`)) - ) plugins.push( processPlugin(path.join(__dirname, `../internal-plugins/prod-404`)) ) diff --git a/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js b/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js index 45a2bc0c20a00..8540086d2d3ca 100644 --- a/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js +++ b/packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js @@ -8,7 +8,7 @@ exports.createPages = async ({ store, boundActionCreators }) => { const currentPath = path.join(__dirname, `./raw_dev-404-page.js`) const newPath = path.join(program.directory, `.cache`, `dev-404-page.js`) - fs.copySync(currentPath, newPath) + await fs.copy(currentPath, newPath) createPage({ component: newPath, From fb70b54fc2322ef11950c3c5ac71e69a88ef9a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sat, 20 Jan 2018 15:39:34 +0100 Subject: [PATCH 4/5] Fix snapshot tests --- .../__snapshots__/gatsby-node.js.snap | 2 +- .../__snapshots__/load-plugins.js.snap | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap b/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap index 45e6fd766758b..12d8f143c72ba 100644 --- a/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap +++ b/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap @@ -40,7 +40,7 @@ apple()", ], "id": "documentationJS node_1 comment #0", "internal": Object { - "contentDigest": "b635e85506044a6cdcebbcd7fda00b7d", + "contentDigest": "e33923a8e75f9ca85da87ace4a55d47e", "type": "DocumentationJs", }, "kind": "constant", diff --git a/packages/gatsby/src/bootstrap/__tests__/__snapshots__/load-plugins.js.snap b/packages/gatsby/src/bootstrap/__tests__/__snapshots__/load-plugins.js.snap index 2602486084c00..5b87a2422b84b 100644 --- a/packages/gatsby/src/bootstrap/__tests__/__snapshots__/load-plugins.js.snap +++ b/packages/gatsby/src/bootstrap/__tests__/__snapshots__/load-plugins.js.snap @@ -2,6 +2,18 @@ exports[`Load plugins Loads plugins defined with an object but without an option key 1`] = ` Array [ + Object { + "id": "Plugin dev-404-page", + "name": "dev-404-page", + "nodeAPIs": Array [ + "createPages", + ], + "pluginOptions": Object { + "plugins": Array [], + }, + "resolve": "", + "version": "1.0.0", + }, Object { "id": "Plugin component-page-creator", "name": "component-page-creator", @@ -39,18 +51,6 @@ Array [ "resolve": "", "version": "1.0.0", }, - Object { - "id": "Plugin dev-404-page", - "name": "dev-404-page", - "nodeAPIs": Array [ - "createPages", - ], - "pluginOptions": Object { - "plugins": Array [], - }, - "resolve": "", - "version": "1.0.0", - }, Object { "id": "Plugin prod-404", "name": "prod-404", @@ -99,6 +99,18 @@ Array [ exports[`Load plugins load plugins for a site 1`] = ` Array [ + Object { + "id": "Plugin dev-404-page", + "name": "dev-404-page", + "nodeAPIs": Array [ + "createPages", + ], + "pluginOptions": Object { + "plugins": Array [], + }, + "resolve": "", + "version": "1.0.0", + }, Object { "id": "Plugin component-page-creator", "name": "component-page-creator", @@ -136,18 +148,6 @@ Array [ "resolve": "", "version": "1.0.0", }, - Object { - "id": "Plugin dev-404-page", - "name": "dev-404-page", - "nodeAPIs": Array [ - "createPages", - ], - "pluginOptions": Object { - "plugins": Array [], - }, - "resolve": "", - "version": "1.0.0", - }, Object { "id": "Plugin prod-404", "name": "prod-404", From dc684186d9d5301da0099d3d00522fd110dff506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sat, 20 Jan 2018 18:37:08 +0100 Subject: [PATCH 5/5] Revert invalid improper snapshot test modification --- .../src/__tests__/__snapshots__/gatsby-node.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap b/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap index 12d8f143c72ba..45e6fd766758b 100644 --- a/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap +++ b/packages/gatsby-transformer-documentationjs/src/__tests__/__snapshots__/gatsby-node.js.snap @@ -40,7 +40,7 @@ apple()", ], "id": "documentationJS node_1 comment #0", "internal": Object { - "contentDigest": "e33923a8e75f9ca85da87ace4a55d47e", + "contentDigest": "b635e85506044a6cdcebbcd7fda00b7d", "type": "DocumentationJs", }, "kind": "constant",