【发布时间】:2020-02-04 11:30:01
【问题描述】:
我正在使用 Gatsby 构建一个网站,并尝试设置一些结构化数据来帮助提高我的搜索可见性。我需要帮助的一点是image 数组中有多个图像。这是我想要的一个例子:
const schemaOrgJSONLD = [
{
"@context": "https://schema.org",
"@type": "EventVenue",
image: [
"https://example.com/photos/1x1/photo.jpg",
"https://example.com/photos/4x3/photo.jpg",
"https://example.com/photos/16x9/photo.jpg",
]
}
]
我有 10 张可以使用 Graphql 检索的图像,并返回它们的 publicURL:
{data.allFile.edges.map(({ node }, i) => node.publicURL)}
这给了我这样的输出:
/static/venue-001.jpg
/static/venue-002.jpg
/static/venue-003.jpg
...
我需要做的是将这些返回的 URL 转换为 Google 将接受的架构标记格式。所以如上所述正确的输出是:
const schemaOrgJSONLD = [
{
"@context": "https://schema.org",
"@type": "EventVenue",
image: [
"https://example.com/static/venue-001.jpg",
"https://example.com/static/venue-002.jpg",
"https://example.com/static/venue-002.jpg",
]
}
]
当涉及到多个图像时,我基本上不知道如何将 graphql 给我的内容转换为有效的模式标记。
【问题讨论】:
标签: json graphql gatsby structured-data