Skip to content

Instantly share code, notes, and snippets.

@colettewilson
Created September 26, 2019 08:11
Show Gist options
  • Save colettewilson/7d52262d44741b2800a8efb5700a6acf to your computer and use it in GitHub Desktop.
Save colettewilson/7d52262d44741b2800a8efb5700a6acf to your computer and use it in GitHub Desktop.
import S from '@sanity/desk-tool/structure-builder'
import { MdWork, MdAccountBalance, MdCached, MdDashboard, MdSettings, MdMail, MdPerson, MdAssignment, MdDescription, MdShoppingCart, MdLightbulb, MdLocalOffer, MdChatBubble } from 'react-icons/lib/md'
// We filter document types defined in structure to prevent
// them from being listed twice
const hiddenDocTypes = listItem =>
!['redirects', 'page', 'newsroom', 'caseStudy', 'product', 'solution', 'site-config', 'contactInfo', 'resource', 'author', 'blog', 'category', 'testimonial'].includes(listItem.getId())
export default () =>
S.list()
.title('Site')
.items([
S.listItem()
.title('Admin')
.icon(MdAccountBalance)
.child(
S.list()
.title('Site settings')
.items([
S.listItem()
.title('Site details')
.icon(MdSettings)
.child(
S.editor()
.id('config')
.schemaType('site-config')
.documentId('global-config')
),
S.listItem()
.title('Redirects')
.icon(MdCached)
.child(
S.editor()
.id('redirects')
.schemaType('redirects')
.documentId('global-redirects')
),
S.listItem()
.title('Contact info')
.icon(MdMail)
.child(
S.editor()
.id('contact')
.schemaType('contactInfo')
.documentId('contact')
),
])
),
S.listItem()
.title('Pages')
.icon(MdDashboard)
.schemaType('page')
.child(S.documentTypeList('page').title('Pages')),
S.listItem()
.title('Products')
.icon(MdShoppingCart)
.schemaType('product')
.child(S.documentTypeList('product').title('Products')),
S.listItem()
.title('Solutions')
.icon(MdLightbulb)
.schemaType('solution')
.child(S.documentTypeList('solution').title('Solutions')),
S.listItem()
.title('Blog')
.icon(MdDescription)
.schemaType('blog')
.child(S.documentTypeList('blog').title('Blog')),
S.listItem()
.title('Case Studies')
.icon(MdAssignment)
.schemaType('caseStudy')
.child(S.documentTypeList('caseStudy').title('Case Study')),
S.listItem()
.title('Resources')
.icon(MdWork)
.schemaType('resource')
.child(S.documentTypeList('resource').title('Resources')),
S.listItem()
.title('Newsroom')
.icon()
.schemaType('newsroom')
.child(S.documentTypeList('newsroom').title('Newsroom')),
S.listItem()
.title('Categories')
.icon(MdLocalOffer)
.schemaType('category')
.child(S.documentTypeList('category').title('Category')),
S.listItem()
.title('Authors')
.icon(MdPerson)
.schemaType('author')
.child(S.documentTypeList('author').title('Authors')),
S.listItem()
.title('Testimonials')
.icon(MdChatBubble)
.schemaType('testimonial')
.child(S.documentTypeList('testimonial').title('Testimonials')),
...S.documentTypeListItems().filter(hiddenDocTypes)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment