Define List Items
Once you have configured the structure, you can use the generated defineListItems helper to build your studio's desk hierarchy. This utility provides comprehensive type safety and IntelliSense tailored to your project's specific configuration.
We recommend keeping your list items in a separate file (e.g., src/structure/listItems.ts).
import { defineListItems } from './index';
const listItems = defineListItems([
{
title: 'General',
isDivider: true,
},
{
schemaType: 'author',
},
{
title: 'Settings',
schemaType: 'settings',
singleton: true,
},
]);
export default listItems;Why use defineListItems?
While you could define your structure as a plain array, using defineListItems offers several key advantages:
- Type Safety: Ensures every item follows the
ListItemschema. - Contextual IntelliSense: If you configured
rolesorworkspacesin your setup, they will be available as autocomplete options within your list items. - Validation: Catches common mistakes, like missing a
titlewhen an item haschildren.
Individual Items
If you need to define and export a single item (for example, to reuse it across different lists), use the defineListItem utility:
import { defineListItem } from './index';
export const blogSection = defineListItem({
title: 'Blog',
schemaType: 'post',
});Key Item Properties
The ListItem configuration supports a wide range of properties. For a full list of available fields and their usage, see the List Items Guide.
Important Note on Workspaces & Roles
The availability of workspaces and roles properties on your list items depends entirely on your initial configuration.
- Workspace Protection: The
workspacesproperty will only be available if they were explicitly configured at the plugin level. - Role Protection: Similarly, if
roleswere not defined during setup, therolesproperty will be hidden from types, preventing you from using the roles.
This strict coupling ensures that your access control logic remains consistent and type-safe throughout your project.
