commerce/lib/sanity/desk/index.ts
2023-08-14 12:24:07 +02:00

74 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Desk structure overrides
*/
import {ListItemBuilder, StructureResolver} from 'sanity/desk'
import categories from './category-structure'
import home from './home-structure'
import pages from './page-structure'
import products from './product-structure'
import settings from './settings-structure'
import blurbs from './blurb-structure'
import sections from './section-structure'
import usps from './usp-structure'
import navigation from './navigation-structure'
/**
* Desk structure overrides
*
* Sanity Studio automatically lists document types out of the box.
* With this custom desk structure we achieve things like showing the `home`
* and `settings` document types as singletons, and grouping product details
* and variants for easy editorial access.
*
* You can customize this even further as your schemas progress.
* To learn more about structure builder, visit our docs:
* https://www.sanity.io/docs/overview-structure-builder
*/
// If you add document types to desk structure manually, you can add them to this function to prevent duplicates in the root pane
const hiddenDocTypes = (listItem: ListItemBuilder) => {
const id = listItem.getId()
if (!id) {
return false
}
return ![
'category',
'home',
'media.tag',
'page',
'product',
'productVariant',
'settings',
'blurb',
'section',
'usp',
'navigation',
'footerMenu',
'utilityMenu'
].includes(id)
}
export const structure: StructureResolver = (S, context) =>
S.list()
.title('Content')
.items([
home(S, context),
pages(S, context),
S.divider(),
products(S, context),
categories(S, context),
S.divider(),
blurbs(S, context),
usps(S, context),
sections(S, context),
S.divider(),
navigation(S, context),
S.divider(),
settings(S, context),
S.divider(),
...S.documentTypeListItems().filter(hiddenDocTypes),
S.divider(),
])