Nat*_*gan 1 javascript reactjs gatsby
当您转到希望缓存的页面时,在页面上(从源插件)调用 touchNode 会导致以下错误:
类型错误:locationAndPageResources.pageResources 未定义
// 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
})
}
}
}
}))
Run Code Online (Sandbox Code Playgroud)
页面节点应该持续存在而不必重新创建它(并且不需要后端)。
| 归档时间: |
|
| 查看次数: |
248 次 |
| 最近记录: |