【问题标题】:ContentFul: Unable to retrieve images in RichTextContentFul:无法检索 RichText 中的图像
【发布时间】:2021-01-19 15:26:21
【问题描述】:

当我在富文本中嵌入图像时,我想我得到了两个响应,sys 和 fields,但为什么我不能得到它们? 该计划正在使用免费计划。

--ps-- 我使用 DeepL

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

【问题讨论】:

  • 您如何请求数据(内容丰富的 REST CDA 或 GraphQL)?
  • 我正在使用 GraphQL 发出请求。

标签: javascript contentful


【解决方案1】:

这里有内容的 DevRel。 ? 要获取链接的资产数据,您必须调整查询以包含它。

对于以下富文本内容

您可以按如下方式检索图像信息。

query {
  quoteCollection(limit: 10) {
    items {
      richText {
        links {
          assets {
            block {
              title
              url
            }
          }
        }
        json
      }
    }
  }
}

在示例查询中,我使用links 字段来访问richText 字段中包含的引用和资产。

You can read more about RichText queries in the docs.

【讨论】:

    猜你喜欢
    • 2020-01-13
    • 2020-05-20
    • 2014-07-02
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    相关资源
    最近更新 更多