1

我一直在尝试向highlightedLinesSanity.io 代码输入添加字段。我发现的唯一文档在模块的npm 页面上,并且有一个示例数据模型:

{
  _type: 'code',
  language: 'js',
  highlightedLines: [1, 2], // <--- I need to have this field accessible in sanity studio
  code: 'const foo = "bar"\nconsole.log(foo.toUpperCase())\n// BAR'
}

我已经尝试(天真地)将fields: { foo: "array" } 属性添加到 中的“代码块”对象blockContent.js,但是工作室没有编译,抛出Cannot override 'fields' of subtypes of "object"错误。

我是否需要分别创建新类型code并用其他字段装饰它?

// current blockContent.js

export default {
  title: "Block Content",
  name: "blockContent",
  type: "array",
  of: [
    {
    // ...  

    {
      type: "image",
      options: { hotspot: true },
    },
    {
      title: "Code block",
      name: "code",
      type: "code",
      options: {
        withFilename: true,
      }
    },
  ],
};

我很乐意接受任何建议。

4

1 回答 1

1

您可以通过单击左侧的行号来突出显示该行。可以添加到文档中:)

高亮代码行

于 2020-12-13T16:12:44.527 回答