Types for custom desk structure and generating schema types in Sanity.io
16 replies
Last updated: Aug 9, 2023
L
Hi, I just created a custom desk structure and I was wondering whether there are built-in types for the
The following is my example code:
However, since there I am currently not using some
Feedback is much appreciated!
😊
Sstructure builder provided by Sanity?
The following is my example code:
export const deskStructure = (S) => S.list() .title('Content') .items([ ...S.documentTypeListItems().filter( (listItem) => !['archive'].includes(listItem.getId()), ), ]);
Stype, there is no intellisense at all.I did look up the official docs on this matter, though I could not seem to find any type for this.
Feedback is much appreciated!
😊
Jul 3, 2023, 4:36 PM
Can you try importing the
StructureResolvertype from
sanity/desk? I think that’ll be what you need.
Jul 3, 2023, 4:47 PM
L
user A
I actually already tried that one before. The structure builder methods don't seem to exist on it, hence using it as the type for Sdoes not work.
Jul 3, 2023, 4:51 PM
L
And while we are at it, what is the recommended way for generating types for your schemas / groq-query responses? 🙂
Jul 3, 2023, 6:14 PM
L
user A
That's it! Thank you very much for your time and help!Would you mind to lead me in the right direction on my other question about generating types for your schemas? 🙂
Jul 3, 2023, 10:04 PM
Great! Glad that’s working for you.
I’ve seen offerings like
codegen and sanity-typed , but haven’t used any of them myself and couldn’t offer much in terms of advice, I’m afraid.
I’ve seen offerings like
codegen and sanity-typed , but haven’t used any of them myself and couldn’t offer much in terms of advice, I’m afraid.
Jul 3, 2023, 10:10 PM
L
user A
Alright, I see! And do you know if there are types for your sanity.config.tsand
schemas/files (like intellisense for creating the actual schemas)?Would make it a lot easier to configure things, without constantly having to check the docs
Jul 3, 2023, 10:16 PM
L
Is that where you use methods like
defineType(),
defineField()and so on?
Jul 3, 2023, 10:19 PM
L
user A
One last question: is there a proper way of excluding a document from the "Create new document" menu at the top-left of your studio?I already have overwritten the document actions in my sanity.config.ts, to not show the delete button from some documents, but I don't want multiple instances of them to exist either.
Jul 3, 2023, 10:24 PM
Yes, please check out this guide . It’s about singletons but covers removing a document type from the create new menu.
Jul 3, 2023, 10:26 PM
L
Thank you! Sometimes I find it hard to actually find these kind of things in your docs.Exceptional support though! Much appreciated!
I wish you a lovely day / evening!
😊
I wish you a lovely day / evening!
😊
Jul 3, 2023, 10:44 PM
Yes, improvement there is an area of focus right now. If there’s anywhere in particular you feel needs work, please feel free to use the feedback component at the bottom of each page.
Glad we were able to help you here! A great day to you as well!
Glad we were able to help you here! A great day to you as well!
Jul 3, 2023, 10:48 PM
L
I see! Will definitely make use of the feedback component!
@sanity-typed/typeslooks quite promising, as it almost feels like it is / should be part of the actual main
sanitypackage (by not introducing new complexity and building on top of the existing functionality instead).However, I am wondering how I should get types, which are inferred using
InferSchemaValues()into my frontend project, as my frontend website and sanity studio projects are separated into different packages in my codespace.
Jul 3, 2023, 10:55 PM
I’d suggest starting a new thread for that, since the original question is resolved and no one will see the question here unless they click into the replies. That way, everyone in the community can see it and hopefully you’ll get some advice. 🙌
Jul 3, 2023, 10:58 PM
L
user A
Sorry, sure thing! There you go: https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1688425861546369 Jul 3, 2023, 11:11 PM
S
More @sanity-typed packages have been released by yours truly... 👀
Aug 9, 2023, 11:57 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.