"Removing mid section and accessing documents directly - desk structure issue"
27 replies
Last updated: Dec 3, 2021
M
Hi there, i need to remove this mid section and want to access documents directly. How to achieve this?
Dec 2, 2021, 11:22 AM
M
code:
const articleStruct = S.listItem()
.title('News')
.icon(ImNewspaper)
.child(
S.list()
.title('Articles')
.items([
S.documentTypeListItem('newsArticle').title('All News Articles').icon(ImNewspaper),
S.documentTypeListItem('latestNews').schemaType('latestNews').title('Latest News Articles').icon(ImNewspaper),
S.documentTypeListItem('featuredNews').schemaType('latestNews').title('Featured News Article').icon(ImNewspaper),
S.divider(),
S.documentTypeListItem('articleCategory').title('Article Categories').icon(FiList),
]),
);
Dec 2, 2021, 11:23 AM
Is this one specific document, or will the document change based on dynamic values elsewhere in the studio?
Dec 2, 2021, 11:52 AM
M
user H
this is due to different desk structure for latest and feature articles. Ive changed some and i got my desired results but now facing a warning.Dec 2, 2021, 11:54 AM
M
missing id issue occuring
Dec 2, 2021, 11:55 AM
Hmm, I’ve only had that error the first time I create a defined page like this - it usually goes away after I publish the document.
Dec 2, 2021, 11:58 AM
M
facing same afetr publishing as well,
Dec 2, 2021, 11:59 AM
Try adding this to the bottom of your structure definition:
It will add an additional item only available in development that will list all document types.
With this you can navigate to your document type and see if your documents exist there.
It will add an additional item only available in development that will list all document types.
process.env.NODE_ENV === "development" ? S.listItem() .title("All Document Types") .child( S.list() .title("All Types") .items([ // This returns an array of all the document types b // defined in schema.js. We filter out those that we have // defined the structure above ...S.documentTypeListItems() /* .filter(hiddenDocTypes) */, ]), ) : S.divider()
Dec 2, 2021, 11:59 AM
Can you open inspect in the top right to view the documents JSON and show the oputput?
Dec 2, 2021, 12:00 PM
M
the weird thing is that these missing id doesn't exist in my model/schema. I have nowhere
featuredNewsArticleand
latestNewsArticle
Dec 2, 2021, 12:00 PM
M
ive added all docuements in structure and latest and feature news are showing
Dec 2, 2021, 12:05 PM
M
here's the code,
const articleStruct = S.listItem()
.title('News')
.icon(ImNewspaper)
.child(
S.list()
.title('Articles')
.items([
S.documentTypeListItem('newsArticle').title('All News Articles').icon(ImNewspaper),
S.documentListItem()
.schemaType('latestNews')
.title('Latest News Articles')
.icon(ImNewspaper)
.child(S.document().schemaType('latestNews').id('latestNews')),
S.documentListItem()
.schemaType('featuredNews')
.title('Featured News Article')
.icon(ImNewspaper)
.child(S.document().schemaType('featuredNews').id('featuredNews')),
//S.documentTypeListItem('latestNews').schemaType('latestNews').title('Latest News Articles').icon(ImNewspaper),
//S.documentTypeListItem('featuredNews').schemaType('latestNews').title('Featured News Article').icon(ImNewspaper),
S.divider(),
S.documentTypeListItem('articleCategory').title('Article Categories').icon(FiList),
]),
);
Dec 2, 2021, 12:06 PM
Could you go back to where you’re having the error.
• In the top right select inspect.
• Screenshot the parsed JSON
• In the top right select inspect.
• Screenshot the parsed JSON
Dec 2, 2021, 12:07 PM
M
id is latestNews but on cms its showing missing id latestNewsArticles. 😶
Dec 2, 2021, 12:11 PM
Looks like you need to delete the document, then return to where you’re seeing the error and recreate it there.
Dec 2, 2021, 12:12 PM
M
already changhed the id in structure but i guess i have to delete and recreate it. Can you share the doc delete cmd??
Dec 2, 2021, 12:14 PM
M
ive deleted but same issue is there as you can see.
Dec 2, 2021, 12:18 PM
M
its same,
Dec 2, 2021, 12:20 PM
M
it looks like desk structure issue,
Dec 2, 2021, 12:21 PM
Try setting an
idon the document list item:
S.documentListItem() .id('featuredNews') .schemaType('featuredNews') .title('Featured News Article') .icon(ImNewspaper)
Dec 2, 2021, 4:38 PM
(if you don't have any custom needs for the child editor, you don't have to specify the
.child()for what it's worth)
Dec 2, 2021, 4:39 PM
M
user Z
user H
i removed the id part in child and it fixed, 🤦♂️Dec 3, 2021, 7:06 AM
M
user Z
user H
i removed the id part and it fixed, 🤦♂️Dec 3, 2021, 7:06 AM
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.