Skip to content

Commit

Permalink
chore(gatsby-source-contentful): cache the cache key (#28444)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdz authored Dec 2, 2020
1 parent 1853f3b commit 1fe3f2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/gatsby-transformer-remark/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,16 @@ module.exports = function remarkExtendNodeType(
}

async function getHTMLAst(markdownNode) {
const cachedAst = await cache.get(htmlAstCacheKey(markdownNode))
const key = htmlAstCacheKey(markdownNode)
const cachedAst = await cache.get(key)
if (cachedAst) {
return cachedAst
} else {
const ast = await getAST(markdownNode, cache)
const htmlAst = markdownASTToHTMLAst(ast)

// Save new HTML AST to cache and return
await cache.set(htmlAstCacheKey(markdownNode), htmlAst)
await cache.set(key, htmlAst)
return htmlAst
}
}
Expand Down

0 comments on commit 1fe3f2d

Please sign in to comment.