Skip to content

Commit

Permalink
feat: added preview and icon fields (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
largis21 authored Jan 27, 2025
1 parent 76c9d79 commit 7591560
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/linkField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ export const linkField = definePlugin<LinkFieldPluginOptions | void>((opts) => {
enableLinkParameters = true,
enableAnchorLinks = true,
customLinkTypes = [],
icon,
preview,
} = opts || {}

const linkType = {
const linkType = defineType({
name: 'link',
title: 'Link',
type: 'object',
icon,
preview,
fieldsets: [
{
name: 'advanced',
Expand Down Expand Up @@ -256,12 +260,12 @@ export const linkField = definePlugin<LinkFieldPluginOptions | void>((opts) => {
input: (props: ObjectInputProps) =>
LinkInput({customLinkTypes, ...props, value: props.value as LinkValue}),
},
}
})

return {
name: 'link-field',
schema: {
types: [defineType(linkType)],
types: [linkType],
},
}
})
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {ComponentType} from 'react'
import type {
BaseSchemaDefinition,
CurrentUser,
ObjectInputProps,
ObjectSchemaType,
Path,
PreviewConfig,
ReferenceFilterOptions,
SanityDocument,
} from 'sanity'
Expand Down Expand Up @@ -158,6 +160,10 @@ export interface LinkFieldPluginOptions {
* ```
*/
customLinkTypes?: CustomLinkType[]

icon?: BaseSchemaDefinition['icon']

preview?: PreviewConfig
}

/**
Expand Down

0 comments on commit 7591560

Please sign in to comment.