0.1.0 • Published 1 year ago

@gearbox-built/sanity-multi-reference v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@gearbox-built/sanity-multi-reference

This is a Sanity Studio v3 plugin.

Installation

npm install @gearbox-built/sanity-multi-reference

or

yarn add @gearbox-built/sanity-multi-reference

Usage

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

import {defineConfig} from 'sanity'
import MultiReferencePlugin from '@gearbox-built/sanity-multi-reference'

export default defineConfig({
  //...
  plugins: [
    MultiReferencePlugin({
      apiVersion: import.meta.env.SANITY_STUDIO_API_VERSION, // Defaults to 2021-10-21
    }),
  ],
})

Schema

import {defineField} from 'sanity'


defineField({
  type: 'multiReference',
  name: 'multiReference',
  title: 'Multi Reference',
  options: {
    types: 'movie',
  },
}),

## Args

#### types

Accepts a single string or array of strings. This is the type of document you wish to reference.
eg:

options: { types: 'movie', 'castMember', 'post', },

## License

[MIT](LICENSE) © Gearbox Built

## Develop & test

This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
with default configuration for build & watch scripts.

See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
on how to run this plugin with hotreload in the studio.