[英]Contentful: Why are Embedded Assets in Rich Text represented inconsistently in Content JSON?
I have a Gatsby-Contentful site I am currently developing, and I have two posts on Contentful which contain Embedded Assets in the Rich Text fields of each post.我有一个 Gatsby-Contentful 网站,我目前正在开发,我有两篇关于 Contentful 的帖子,其中每篇帖子的富文本字段中都包含嵌入式资产。
In one Rich Text field, this embedded asset appears as follows:在一个富文本字段中,此嵌入资产显示如下:
{
"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"
}
}
while in another post's Rich Text field it is missing a lot of the data:而在另一个帖子的富文本字段中,它缺少大量数据:
{
"data": {
"target": {
"sys": {
"id": "c5N0u9h6AksECP8JZEzOe1D",
"type": "Link",
"linkType": "Asset"
}
}
},
"content": [],
"nodeType": "embedded-asset-block"
}
}
Why is there such a discrepancy, when I have embedded the images in both Rich Text fields in exactly the same way?当我以完全相同的方式将图像嵌入到两个富文本字段中时,为什么会出现这种差异?
当我遇到这种情况时,我通常必须删除缓存 (root/.cache) 和公共 (root/public) 文件夹并重新启动服务器以从 Contentful 获取正确的数据。
This happens because your cached files not correctly updated during the rebuild.发生这种情况是因为您的缓存文件在重建期间未正确更新。
Just install Gatsby CLI with npm install -g gatsby-cli
只需使用npm install -g gatsby-cli
安装 Gatsby CLI
Then gatsby clean
然后gatsby clean
Then gatsby develop
然后gatsby develop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.