UNPKG

sanity-plugin-computed-field

Version:

Sanity plugin that computes a field's value based on other fields or relationships with its document or external data. In other words, this field memoizes a value in a document using GROQ to lookup and custom javascript to compute the value from those GRO

26 lines (22 loc) 740 B
import {definePlugin} from 'sanity' import {computedBooleanSchema} from './schema/computedBoolean' import {computedNumberSchema} from './schema/computedNumber' import {computedStringSchema} from './schema/computedString' import {computedTextSchema} from './schema/computedText' export interface ComputedFieldPluginConfig { /* nothing here yet */ } // eslint-disable-next-line @typescript-eslint/no-unused-vars export const sanityComputedField = definePlugin<ComputedFieldPluginConfig | void>((config = {}) => { return { name: 'sanity-plugin-computed-field', schema: { types: [ computedBooleanSchema, computedStringSchema, computedTextSchema, computedNumberSchema, ], }, } })