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-transformer-remark): correctly pass cache to sub plugins #10892

Merged
merged 8 commits into from
Jan 8, 2019
Prev Previous commit
Next Next commit
chore: test broken test
  • Loading branch information
DSchau committed Jan 8, 2019
commit 6e9bb33cd3901fc60f95fae4fb6edcbde47c5a17
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ This is a truly meaningful blog post

<h2 data-testid="sub-title">%SUB_TITLE%</h2>

<h2 data-testid="gatsby-remark-subcache-value"></h2>
<h2 data-testid="gatsby-remark-subcache-value">%SUBCACHE_VALUE%</h2>
2 changes: 1 addition & 1 deletion e2e-tests/development-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"serve": "gatsby serve",
"start": "npm run develop",
"format": "prettier --write \"src/**/*.js\"",
"test": "npm run start-server-and-test || npm run reset",
"test": "npm run start-server-and-test || npm run reset && exit 1",
"posttest": "npm run reset",
"reset": "node scripts/reset.js",
"update": "node scripts/update.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function remarkPlugin({ cache, markdownAST }) {
visit(markdownAST, `html`, async node => {
if (node.value.match(id)) {
const value = await cache.get(id)
node.value = node.value.replace(/></, () => `>${value}<`)
node.value = node.value.replace(/%SUBCACHE_VALUE%/, () => `>${value}<`)
}
})
}
2 changes: 1 addition & 1 deletion e2e-tests/development-runtime/src/components/title.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import React from "react"

export default () => <h1 data-testid="title">{`%TITLE%`}</h1>
export default () => <h1 data-testid="title">{`The title`}</h1>
5 changes: 2 additions & 3 deletions packages/gatsby-transformer-remark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@
],
"license": "MIT",
"peerDependencies": {
"gatsby": "^2.0.33"
"gatsby": "^2.0.88"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-remark",
"scripts": {
"build": "babel src --out-dir . --ignore **/__tests__",
"prepare": "cross-env NODE_ENV=production npm run build",
"watch": "babel -w src --out-dir . --ignore **/__tests__"
},
"gitHead": "5bd5aebe066b9875354a81a4b9ed98722731c465"
}
}