当您转到希望缓存的页面时,在页面上(从源插件)调用touchNode会导致以下错误:
TypeError:locationAndPageResources.pageResources未定义
touchNode call:
// Code here checks if the page node in Gatsby cache is the same version
// as backend version. If so 'touch it' and don't recreate.
await Promise.all(result.data.pages.map(async page => {
const pageCacheKey = `cache-${page.url}`
const cacheResult = await pageRecords.getKey(pageCacheKey)
if (cacheResult) {
const node = pageNodes.find(node => {
if (!node.context)
return
return node.context.url == page.url
})
if (node) {
if (node.context.lastPublishedAt == page.lastPublishedAt) {
pageRecords.setKey(pageCacheKey, localPublishedAt)
return touchNode({
nodeId: node.id
})
}
}
}
}))
预期结果
页面节点应该持久存在,而不必重新创建它(并且不需要后端)。
实际结果
最佳答案
删除index.js文件后,我得到了同样的错误。
我先运行gatsby clean
,然后运行gatsby develop
。这样就解决了问题。
关于javascript - Gatsby :在页面节点上调用`touchNode`会引发“TypeError:locationAndPageResources.pageResources未定义”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58464105/