sanity-io / orderable-document-list

Drag-and-drop Document Ordering without leaving the Editing surface
MIT License
73 stars 22 forks source link

Programmaticaly change order of list #69

Open marcodallagatta opened 1 year ago

marcodallagatta commented 1 year ago

Hello, I'm trying to set up my Sanity so that daily (or weekly/etc) the order of a Document List will change.

What I'm trying to do is to shift all elements by "1", basically rotating the whole list, so that if I have 7 elements and they change daily, every day the list would rotate and have a different document shown first.

How would I go about this? My idea was to edit the orderRank via GROQ mutation, but the actual field doesn't show a simple number, for example my first element now says 0|100008: and the second 0|10000o:. Would using lexoRank.genNext() be the way, as in the source code?

Thanks for the help!