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:
Paul
2024-07-10 11:22:12 -04:00
committed by GitHub
parent 8ea87afd24
commit 2bc8666bff
4 changed files with 97 additions and 65 deletions

View File

@@ -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',
},
],
},