Contentful:为什么富文本中的嵌入资产在内容 JSON 中表示不一致?

Contentful: Why are Embedded Assets in Rich Text represented inconsistently in Content JSON?

我目前正在开发一个 Gatsby-Contentful 网站,我在 Contentful 上有两个 post,每个 post.[=13= 的富文本字段中都包含嵌入式资产]

在一个富文本字段中,此嵌入资产显示如下:

{
"data": {
                      "target": {
                        "sys": {
                          "space": {
                            "sys": {
                              "type": "Link",
                              "linkType": "Space",
                              "id": "aw0p4zkj7lhv"
                            }
                          },
                          "id": "c5N0u9h6AksECP8JZEzOe1D",
                          "type": "Asset",
                          "createdAt": "2019-07-29T11:48:08.826Z",
                          "updatedAt": "2019-07-29T11:48:08.826Z",
                          "environment": {
                            "sys": {
                              "id": "master",
                              "type": "Link",
                              "linkType": "Environment"
                            }
                          },
                          "revision": 1
                        },
                        "fields": {
                          "title": {
                            "en-US": "dummy"
                          },
                          "description": {
                            "en-US": "dummy so api works"
                          },
                          "file": {
                            "en-US": {
                              "url": "//images.ctfassets.net/aw0p4zkj7lhv/5N0u9h6AksECP8JZEzOe1D/af219e63f6e381c7124a6d65a0fe85e0/test.jpg",
                              "details": {
                                "size": 58342,
                                "image": {
                                  "width": 1000,
                                  "height": 666
                                }
                              },
                              "fileName": "test.jpg",
                              "contentType": "image/jpeg"
                            }
                          }
                        }
                      }
                    },
                    "content": [],
                    "nodeType": "embedded-asset-block"
                  }
}

而在另一个 post 的富文本字段中,它缺少大量数据:

{
"data": {
                      "target": {
                        "sys": {
                          "id": "c5N0u9h6AksECP8JZEzOe1D",
                          "type": "Link",
                          "linkType": "Asset"
                        }
                      }
                    },
                    "content": [],
                    "nodeType": "embedded-asset-block"
                  }
}

当我以完全相同的方式将图像嵌入到两个富文本字段中时,为什么会出现这样的差异?

当我遇到这种情况时,我通常必须删除缓存 (root/.cache) 和 public (root/public) 文件夹并重新启动服务器以从 Contentful 获取正确的数据.

发生这种情况是因为您的缓存文件在重建期间未正确更新。

只需使用 npm install -g gatsby-cli

安装 Gatsby CLI

然后gatsby clean

然后gatsby develop