sanity-plugin-user-select-input
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

This is a Sanity Studio v3 plugin.

sanity-plugin-user-select-input

This is a Sanity Studio v3 plugin

Adds a searchable dropdown for all users on the project, and stores their User ID as a string field.

Note: Think of the string as a weak reference. Users can be removed from the project without first checking if their ID is used in any Document. And once removed their ID will remain stored as the field value.

This is not a replacement for creating your schema types like staff, author, profile, person etc. It's useful for using a single field to link a document to a user. For example a field like brief, task, reviewer etc.

Installation

npm install sanity-plugin-user-select-input

Screenshot 2023-03-20 at 19 34 18

Usage

Add it as a plugin in sanity.config.ts (or .js):

// ./sanity.config.ts

import {defineConfig} from 'sanity'
import {userSelect} from 'sanity-plugin-user-select-input'

export default defineConfig({
  //...
  plugins: [userSelect()],
})

Add a userSelect type field to any document type. It will act like a string field and so can be extended such as using validation rules such as required.

defineField({
  name: 'userId',
  type: 'userSelect',
}),

License

MIT © Simeon Griggs

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.

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

Readme

Keywords

Package Sidebar

Install

npm i sanity-plugin-user-select-input

Weekly Downloads

189

Version

2.0.1

License

MIT

Unpacked Size

794 kB

Total Files

16

Last publish

Collaborators

  • simeongriggs