2

我有一组文档,我希望编辑能够选择它们出现的顺序。我一直无法找到有关此的任何信息。在 Sanity 或插件中是否有标准或内置的方法来处理这个问题?

我可以sortOrder在文档中添加一个字段,但编辑必须填写数字。在列表的前面插入一个文档意味着在它之后手动增加每个文档。

我尝试创建一个包含type: 'array', of: [{ type: 'reference', to: [{ type: 'myType' }] }]. 这确实有效,但它似乎是一种解决方法,并不能带来良好的编辑体验。您必须创建一个新文档,然后转到此单例文档并将其添加到那里。它似乎也查询得更慢。

有什么建议吗?是否已经有一种我错过的好方法可以做到这一点?

4

1 回答 1

2

Currently, your best out-of-the-box option is what you suggest: Create a singleton which has an array of references to the documents you want ordered. But as you point out, this will require new documents to be added manually in a separate context. Which amounts to a clunky user experience.

On the deep end of the pool, you could create a custom input component which allows the order be controlled from within any orderable document, but persists that order (automatically, under the hood) to a singleton.

If you end up with the latter solution, it would be totally awesome if you could share the result. There are several others who have been looking for a solution to the same problem.

于 2019-04-05T06:55:30.470 回答