chore(plugin-search): format
This commit is contained in:
@@ -24,32 +24,32 @@ Core features:
|
|||||||
In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options):
|
In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { buildConfig } from "payload/config";
|
import { buildConfig } from 'payload/config'
|
||||||
import search from "@payloadcms/plugin-search";
|
import search from '@payloadcms/plugin-search'
|
||||||
|
|
||||||
const config = buildConfig({
|
const config = buildConfig({
|
||||||
collections: [
|
collections: [
|
||||||
{
|
{
|
||||||
slug: "pages",
|
slug: 'pages',
|
||||||
fields: [],
|
fields: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: "posts",
|
slug: 'posts',
|
||||||
fields: [],
|
fields: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
search({
|
search({
|
||||||
collections: ["pages", "posts"],
|
collections: ['pages', 'posts'],
|
||||||
defaultPriorities: {
|
defaultPriorities: {
|
||||||
pages: 10,
|
pages: 10,
|
||||||
posts: 20,
|
posts: 20,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
})
|
||||||
|
|
||||||
export default config;
|
export default config
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
@@ -66,11 +66,11 @@ The default priorities first set on `create` operations. Send an object of colle
|
|||||||
plugins: [
|
plugins: [
|
||||||
searchPlugin({
|
searchPlugin({
|
||||||
defaultPriorities: {
|
defaultPriorities: {
|
||||||
pages: ({ doc }) => (doc.title.startsWith("Hello, world!") ? 1 : 10),
|
pages: ({ doc }) => (doc.title.startsWith('Hello, world!') ? 1 : 10),
|
||||||
posts: 20,
|
posts: 20,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
];
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `searchOverrides`
|
#### `searchOverrides`
|
||||||
@@ -81,10 +81,10 @@ Override anything on the search collection by sending a [Payload Collection Conf
|
|||||||
plugins: [
|
plugins: [
|
||||||
searchPlugin({
|
searchPlugin({
|
||||||
searchOverrides: {
|
searchOverrides: {
|
||||||
slug: "search-results",
|
slug: 'search-results',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
];
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `beforeSync`
|
#### `beforeSync`
|
||||||
@@ -97,10 +97,10 @@ plugins: [
|
|||||||
beforeSync: ({ originalDoc, searchDoc }) => ({
|
beforeSync: ({ originalDoc, searchDoc }) => ({
|
||||||
...searchDoc,
|
...searchDoc,
|
||||||
// Modify your docs in any way here, this can be async
|
// Modify your docs in any way here, this can be async
|
||||||
excerpt: originalDoc?.excerpt || "This is a fallback excerpt",
|
excerpt: originalDoc?.excerpt || 'This is a fallback excerpt',
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
];
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `syncDrafts`
|
#### `syncDrafts`
|
||||||
@@ -116,7 +116,7 @@ If true, will delete documents from search that change to draft status. True by
|
|||||||
All types can be directly imported:
|
All types can be directly imported:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { SearchConfig, BeforeSync } from "@payloadcms/plugin-search/dist/types";
|
import { SearchConfig, BeforeSync } from '@payloadcms/plugin-search/dist/types'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default buildConfig({
|
|||||||
serverURL: 'http://localhost:3000',
|
serverURL: 'http://localhost:3000',
|
||||||
admin: {
|
admin: {
|
||||||
user: Users.slug,
|
user: Users.slug,
|
||||||
webpack: config => {
|
webpack: (config) => {
|
||||||
const newConfig = {
|
const newConfig = {
|
||||||
...config,
|
...config,
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": [
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext"
|
|
||||||
],
|
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "../",
|
"rootDir": "../",
|
||||||
"jsx": "react",
|
"jsx": "react"
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"transpileOnly": true
|
"transpileOnly": true
|
||||||
|
|||||||
2
packages/plugin-search/types.d.ts
vendored
2
packages/plugin-search/types.d.ts
vendored
@@ -1 +1 @@
|
|||||||
export * from './dist/types';
|
export * from './dist/types'
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module.exports = require('./dist/types');
|
module.exports = require('./dist/types')
|
||||||
|
|||||||
Reference in New Issue
Block a user