@selvklart/sanity-plugin-desk-hierarchy
v1.0.2
Published
> This is a **Sanity Studio v3** plugin.
Downloads
37
Readme
@selvklart/sanity-plugin-desk-hierarchy
This is a Sanity Studio v3 plugin.
Installation
npm install @selvklart/sanity-plugin-desk-hierarchy
Usage
Add it as a plugin in sanity.config.ts
(or .js):
import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {createDeskHierarchy, deskHierarchyPlugin} from '@selvklart/sanity-plugin-desk-hierarchy'
export default defineConfig({
//...
plugins: [
deskHierarchyPlugin(),
deskTool({
structure: (S) => S.list()
.items([
createDeskHierarchy(S, {
title: 'Category structure',
// The hierarchy will be stored in this document ID 👇
documentId: 'categories_map',
// Document types editors should be able to include in the hierarchy
referenceTo: ['category']
}),
...S.documentTypeListItems().filter((li) => li.getId() !== 'hierarchy.tree')
])
}),
],
})
Notice that we have hidden the internal "hierarchy.tree" document type
License
MIT © Selvklart AS
Develop & test
This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.
See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.