我在理智中有内容块,如下所示:
export default {
title: "Block Content",
name: "blockContent",
type: "array",
of: [
/// stuff here
{
title: "Book",
type: "reference",
to: [{ type: "book" }],
},
],
};
Run Code Online (Sandbox Code Playgroud)
当进行如下查询时
'*[_type == "post"]{...,body[]{..., asset->{..., "_key": _id}, markDefs[]{..., _type == "internaLink" => {"slug": @.reference->slug}}}';
Run Code Online (Sandbox Code Playgroud)
我得到了参考,但我想返回完整的文档。我尝试了每种方法,但文档仅解释了内容块之外的引用,并且这些方法不起作用。
这是查询返回的内容:
_createdAt: '2020-12-07T14:43:34Z',
_id: '9d628aa6-aba7-4b53-aa9f-c6e97583baf9',
_rev: 'ZZ0GkIKCRvD0tdMQPywPfl',
_type: 'post',
_updatedAt: '2020-12-07T14:43:34Z',
body: [
{
_key: '4184df372bae',
_type: 'block',
children: [Array],
markDefs: [],
style: 'normal'
},
{
_key: '56bed8835a7d',
_ref: 'dc2eefee-2200-43e1-99c7-ea989dda16ba',
_type: 'reference'
}
],
title: 'Example'
Run Code Online (Sandbox Code Playgroud)
解决了,我在这里写下解决方案,因为我在网上找不到任何东西。基本上我随机尝试任何东西,直到得到想要的结果。查询是:
_type=="reference"=>^->
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1851 次 |
| 最近记录: |