Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Implementation of document internationalization and organization of pages in a list item discussed.

8 replies
Last updated: May 19, 2022
Help me implement this: https://github.com/sanity-io/document-internationalization/blob/main/docs/known-caveats.md#usage-with-singletons
If I add that code to

export default () => S.list()
  .id('__root__')
  .title('Content')
  ..items([
    [add here?], <---- Throws error! Expected List item, found Object
    S.divider(),
    ...restOfTypes
  ])
May 19, 2022, 6:22 PM
The only thing that can be a direct descendent of
S.list()
is a
S.listItem()
. You'll need to add it before the
documentList
bit.
export default () => S.list()
  .id('__root__')
  .title('Content')
  ..items([
    S.listItem()
      .title('<your-title>')
      .child(
        S.documentList()
         .id('schemaType')
         .title('My Schema Type')
         .schemaType('schemaType')
         .filter('_id == $id && _type == $type')
         .params({
            id: 'schemaType',
            type: 'schemaType',
          })
  .menuItems([
    {
      title: 'Create new',
      intent: {
        type: 'create',
        params: {
          id: 'schemaType',
          type: 'schemaType',
          template: 'schemaType'
        }
      }
    }
  ]))
    S.divider(),
    ...restOfTypes
  ])
May 19, 2022, 6:38 PM
Thank you, Is Working!
Any way to group them?
Let say this is homePage.
Group singleton homePage, aboutPage on a list item called
Pages
?
May 19, 2022, 6:53 PM
Something like this?
Content
|_Pages
  |_homePage
  |_aboutPage
Or am I misunderstanding?
May 19, 2022, 7:08 PM
Yes. Applying same logic as above, with singletons
May 19, 2022, 7:09 PM
Ah, got it. In my studio I add them like this:
S.listItem()
      .title('Sandbox')
      .icon(MdOutlineBugReport)
      .child(S.document().schemaType('sandbox').documentId('sandbox')),
    S.listItem()
      .title('Custom Input Examples')
      .icon(MdCode)
      .child(
        S.document()
          .schemaType('allInputExamples')
          .documentId('allInputExamples')
      ),
    S.divider(),
May 19, 2022, 7:15 PM
Have you tried this solution of switching locales? For base locale, it shows perfect, however changing locales shows nothing.
I'm thinking to tweak the first code you gave me:

• Change the GROQ filter to show a list of ID's (homePage, aboutPage), not just one.
• Creating specific menu item for each page, like Create HomePage , Create AboutPage .
May 19, 2022, 7:26 PM
Made it work with tweaks above. Thank you for helping me 🙌
May 19, 2022, 7:50 PM
Awesome! Glad you got it working!
May 19, 2022, 7:51 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.

Was this answer helpful?