Troubleshooting bypassing document creation in Sanity Studio
41 replies
Last updated: Dec 6, 2021
B
Hi everyone, I'm working on building out my own page builder and I came across Kitchen Sink and saw that in their studio they have a content type of siteSettings, when you click on this it take you right into the editor instead of choosing to create a new document. My question is, how can I bypass having a user create a new document and go right to editing. Screenshot for reference (want to bypass the red circle)
Dec 6, 2021, 6:58 PM
B
Great thank you
Dec 6, 2021, 7:10 PM
B
When I created that structure builder, it left my studio blank, removed all the content
Dec 6, 2021, 7:30 PM
R
You likely left out
...S.documentTypeListItems()as noted in the snippet at the end of this section.
Dec 6, 2021, 7:32 PM
B
This happens when I try to create a new document
Dec 6, 2021, 7:37 PM
R
It would be helpful if you would copy/paste your Structure here.
Dec 6, 2021, 7:41 PM
B
export default () => { S.list() .title('Content') .items([ S.list() .title('Settings') .child( S.document() .schemaType('siteSettings') .documentId('siteSettings') ), S.divider(), ...S.documentTypeListItems().filter(item => !['siteSettings'].includes(item.getId())) ]) }
Dec 6, 2021, 7:45 PM
R
Did you create a
siteSettingsdocument?
Dec 6, 2021, 7:47 PM
B
yes I did
Dec 6, 2021, 7:47 PM
B
I even tried adding some of the other schemas I have to this list
import S from '@sanity/desk-tool/structure-builder' import pages from './schemas/pages' import team from './schemas/team' import pageBuilder from './schemas/pageBuilder' export default () => { S.list() .title('Content') .items([ S.documentListItem() .schemaType('siteSettings') .title('Site Settings') .child( S.document() .schemaType('siteSettings') .documentId('siteSettings') ), S.divider(), pages, team, pageBuilder, ...S.documentTypeListItems().filter(item => !['siteSettings'].includes(item.getId())) ]) }
Dec 6, 2021, 7:49 PM
B
and still nothing
Dec 6, 2021, 7:49 PM
R
What version of the studio are you running?
Dec 6, 2021, 7:52 PM
B
version 1.0.0
Dec 6, 2021, 7:53 PM
B
sanity core 2.22.3
Dec 6, 2021, 7:53 PM
B
https://github.com/briannelson95/example-client/tree/main/server Not sure if this is helpful but I made my repository pubic
Dec 6, 2021, 8:10 PM
R
I see that you created the
siteSettingsschema, but to clarify a previous question, did you also create a document before trying to isolate the singleton in the structure?
Dec 6, 2021, 8:26 PM
B
Yes I created a few documents but deleted the siteSettings doc before learning the document structure
Dec 6, 2021, 8:28 PM
B
And now none of that data is there after implementing the desk structure, and can't even create any documents
Dec 6, 2021, 8:29 PM
R
The data is still there, your Studio just isn't capable of rendering a child that does not exist. If you don't have a
It should just give you all of the documents in your schema. Then, create the actual
siteSettingsdocument, but you've told your Structure to render it, it'll throw an error. For now, change your structure to:
export default () => { S.list() .title('Content') .items([ ...S.documentTypeListItems() ]) }
siteSettingsdocument and try to isolate it as a singleton.
Dec 6, 2021, 8:37 PM
B
Hmm okay I'll try that
Dec 6, 2021, 8:38 PM
R
Once you've got your regular structure back, let me know if you have issues moving forward!
Dec 6, 2021, 8:41 PM
B
That didnt work, I even tried reverting the sanity.json file back to not include the part:@sanity/desk-tool/structure
Dec 6, 2021, 8:45 PM
B
and that didnt work either
Dec 6, 2021, 8:45 PM
R
Can you clarify what you mean by it doesn't work? What error are you getting?
Dec 6, 2021, 8:51 PM
B
Here's what my studio looks like after doing this
Dec 6, 2021, 8:52 PM
R
Ok, now your Studio has no desk structure defined so it can't display your stuff. Can you push your current studio to that repo you shared? I'll clone it and find the error.
Dec 6, 2021, 8:53 PM
B
its been pushed
Dec 6, 2021, 8:54 PM
R
OK, got it working. Replace your desk structure with the following, then save and recompile:
Let me know if that restores your basic structure.
import S from '@sanity/desk-tool/structure-builder' export default () => S.list() .title('Base') .items( S.documentTypeListItems() )
Dec 6, 2021, 9:02 PM
R
OK, got it working. Replace your desk structure with the following, then save and recompile:
Let me know if that restores your basic structure.
import S from '@sanity/desk-tool/structure-builder' export default () => S.list() .title('Base') .items( S.documentTypeListItems() )
Dec 6, 2021, 9:02 PM
B
Same result still not showing data
Dec 6, 2021, 9:15 PM
B
is it a problem with my sanity.json file?
"parts": [ { "name": "part:@sanity/base/schema", "path": "./schemas/schema" }, { "name": "part:@sanity/desk-tool/structure", "path": "./deskStructure.js" } ]
Dec 6, 2021, 9:15 PM
R
No, I cloned your repo and only changed the desk structure and it worked, so your sanity.json should be fine.
Dec 6, 2021, 9:16 PM
B
Do I have to run sanity build again?
Dec 6, 2021, 9:17 PM
R
All I did was quit the server then run
sanity startto recompile.
Dec 6, 2021, 9:18 PM
B
Okay so I tried it on a different computer and it worked, maybe I was cached
Dec 6, 2021, 9:21 PM
B
So I shouldn't try doing that again? Lol
Dec 6, 2021, 9:22 PM
R
Naw, we'll get it working. Let me make sure it works for me then I'll give you the steps.
Dec 6, 2021, 9:22 PM
B
The whole sanity team is awesome thanks for helping me out
Dec 6, 2021, 9:23 PM
R
Very happy to help! Structure builder is difficult to work with at first.
So, I was wrong about needing to publish a siteSettings document first, since you don't have
So, I was wrong about needing to publish a siteSettings document first, since you don't have
__experiment_actionsenabled yet. If you just change your desk structure to the following, does it open a settings document editor?
import S from '@sanity/desk-tool/structure-builder' export default () => S.list() .title('Base') .items([ S.listItem() .title('Settings') .child( S.document() .schemaType('siteSettings') .documentId('siteSettings') ), ...S.documentTypeListItems().filter(listItem => !['siteSettings'].includes(listItem.getId())) ])
Dec 6, 2021, 9:26 PM
B
That seemed to have work, I’m able to click on settings and can edit that document
Dec 6, 2021, 9:29 PM
B
Thank you!
Dec 6, 2021, 9:30 PM
R
You're welcome!
Dec 6, 2021, 9:31 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.