feat(plugin-search)!: make search collection fields override into a function that provides defaultFields inline with other plugins (#7095)
searchPlugin's searchOverrides for the collection now takes in a fields
function instead of array similar to other plugins and patterns we use
to allow you to map over existing fields as well if needed.
```ts
// before
searchPlugin({
searchOverrides: {
slug: 'search-results',
fields: [
{
name: 'excerpt',
type: 'textarea',
admin: {
position: 'sidebar',
},
},
]
},
}),
// current
searchPlugin({
searchOverrides: {
slug: 'search-results',
fields: ({ defaultFields }) => [
...defaultFields,
{
name: 'excerpt',
type: 'textarea',
admin: {
position: 'sidebar',
},
},
]
},
}),
```
This commit is contained in:
@@ -41,14 +41,14 @@ export default buildConfigWithDefaults({
|
||||
posts: ({ title }) => (title === 'Hello, world!' ? 30 : 20),
|
||||
},
|
||||
searchOverrides: {
|
||||
fields: [
|
||||
fields: ({ defaultFields }) => [
|
||||
...defaultFields,
|
||||
{
|
||||
name: 'excerpt',
|
||||
type: 'text',
|
||||
type: 'textarea',
|
||||
admin: {
|
||||
readOnly: true,
|
||||
position: 'sidebar',
|
||||
},
|
||||
label: 'Excerpt',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user