javascript - Sanity CMS,在文档中引用数组
问题描述
我的目标是有一个自定义的 internalLink 标记,它不仅可以引用帖子(因为它很容易,因为它 a type: document
)而且还可以引用name: sections
返回数组的section.js
. 这样,编辑者可以链接到帖子文档中的任何部分。理想情况下,编辑也可以访问其他帖子部分,而不仅仅是当前打开的部分。
我希望能够section.js
在参考下拉列表中参考以下集合:
现在我明白参考仅适用于type: document
. 我可以让它为 的孩子(数组或对象)工作type: post
吗?
我的自定义 block.js
marks: {
...
annotations: [
{
name: "internalLink",
title: "Internal link",
type: "object",
fields: [
{
name: "linkto",
type: "reference",
title: "Link To",
to: [{ type: "post" }],
},
],
},
...
post.js
export default {
name: "post",
title: "Document",
type: "document",
fields: [
...
{
name: "sections",
title: "Sections",
type: "array",
of: [{ type: "section" }],
},
],
}
节.js
export default {
title: "Section",
name: "section",
type: "object",
fields: [
{
name: "sectionTitle",
title: "Section Title",
type: "string",
},
{
title: "Content",
name: "content",
type: "blockContent",
},
],
}
感谢我能得到的任何帮助/指示:)
解决方案
推荐阅读
- python - 熊猫自定义功能,以查找是否是第一个,第二个等星期一,星期二等 - 欢迎所有建议
- c# - 将文件移动到另一个文件夹但被视为丢失
- java - 为什么我的 gif 只有在我单击 ImageView 时才会加载?
- typescript - 在 TypeScript 中,推断动态参数是动态函数的参数
- discord - Discord.py 命令上的命令错误消息
- azure-active-directory - 如何使用 Graph API 通过 id 或 userPrincipalName 获取用户对象?
- typescript - 用于对象的名为 arg 的打字稿
- ffmpeg - 如何使用ffmpeg在视频的最后5秒排除水印覆盖
- pine-script - 如何更改满足我在 Pine Script 中的蜡烛标准/定义的蜡烛的蜡烛颜色?
- react-native - React-native : 自签名认证实现