sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
5.23k stars 425 forks source link

Mirror the `schemas/` folder structure in the studio UI #3978

Open pascalwengerter opened 1 year ago

pascalwengerter commented 1 year ago

I'm evaluating Sanity as a headless CMS at my current job, and one of the first things the marketing department gave as feedback was the risk of drowning in all the individual schemas, which currently are listed all below each other (and we're just getting started on a not-even-that-big-project).

Sanity could take inspiration from what e.g. Nuxt/NextJS do and provide file-based routing inside the schemas/ folder, at least by default or as configuration option? IIRC there is a way of building this yourself using React, but akin to #3871 this feels like a dearly needed improvement to make Sanity a feasible choice for medium/large projects 😎 Also not sure whether this brings implication akin to #1358

Here's two screenshots of the current small-scale setup which potentially makes the problematic more understandable:

Screenshot 2022-12-15 at 16-24-30 Polarstern CMS – Desk

Screenshot 2022-12-15 at 16 25 37

toddpadwick commented 1 year ago

This is possible @pascalwengerter but requires fiddling around with the structure builder which is tedious and not a very user-friendly syntax - I often have to do this to group things like global settings and sitewide structures like the below screenshot. So although possible, your suggestion of using a 'nuxt like' directory structure approach is a great idea and would make doing so much easier!

Screenshot 2022-12-23 at 12 11 45
import S from '@sanity/desk-tool/structure-builder'
import { FiSettings, FiHome, FiMenu, FiSearch, FiCreditCard } from "react-icons/fi";

export default () =>
  S.list()
    .title('Content')
    .items([

      S.listItem().title('Settings').icon(FiSettings).child(
        S.list().title('Settings').items([
          S.listItem().title('Header banner').icon(FiCreditCard).child(
            S.document().title('Header banner').schemaType('headerBanner').documentId('headerBanner')
          ),
          S.listItem().title('Navigation').icon(FiMenu).child(
            S.document().title('Navigation').schemaType('navigation').documentId('navigation')
          ),
          S.listItem().title('SEO').icon(FiSearch).child(
            S.document().title('SEO').schemaType('seo').documentId('seo')
          ),
          S.listItem().title('Redirects').schemaType('redirect').child(
            S.documentTypeList('redirect')
          )
        ])
      ),
      S.divider(),
      S.listItem().title('Home page').schemaType('homePage').child(
        S.editor().title('Home page').schemaType('homePage').documentId('homePage')
      ),
      S.listItem().title('Solutions').schemaType('solution').child(
        S.documentTypeList('solution')
      ),
      S.listItem().title('Industries').schemaType('industry').child(
        S.documentTypeList('industry')
      ),
      S.listItem().title('Organisational Roles').schemaType('role').child(
        S.documentTypeList('role')
      ),
      S.listItem().title('Landing Pages').schemaType('landingPage').child(
        S.documentTypeList('landingPage')
      ),
      S.listItem().title('About Pages').schemaType('about').child(
        S.documentTypeList('about')
      ),
    ])