@selvklart/sanity-plugin-desk-hierarchy
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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.

Readme

Keywords

Package Sidebar

Install

npm i @selvklart/sanity-plugin-desk-hierarchy

Weekly Downloads

9

Version

1.0.2

License

MIT

Unpacked Size

11 MB

Total Files

44

Last publish

Collaborators

  • jostein-selvklart
  • tafkolstad
  • wien
  • joakim.selvklart
  • sanders54