| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
const path = '/extendify/v1/agent/content-search'; |
| 5 |
|
| 6 |
export const contentSearch = { |
| 7 |
name: 'extendify/content-search', |
| 8 |
label: __('Site text', 'extendify-local'), |
| 9 |
description: |
| 10 |
'Find which of this site’s posts, pages, headers, footers and patterns say something, and read the words around each match. It searches the text a visitor sees, so wording that only appears once a pattern or shortcode has run is found too. Look for a single word or a short phrase, not a sentence.', |
| 11 |
inputSchema: { |
| 12 |
type: 'object', |
| 13 |
properties: { |
| 14 |
query: { |
| 15 |
type: 'string', |
| 16 |
description: 'The word or short phrase to look for.', |
| 17 |
}, |
| 18 |
postTypes: { |
| 19 |
type: 'array', |
| 20 |
items: { type: 'string' }, |
| 21 |
description: |
| 22 |
'Which post types to look through. Defaults to posts, pages, template parts and patterns.', |
| 23 |
}, |
| 24 |
limit: { |
| 25 |
type: 'integer', |
| 26 |
minimum: 1, |
| 27 |
maximum: 25, |
| 28 |
description: 'How many posts to return. Defaults to 10.', |
| 29 |
}, |
| 30 |
context: { |
| 31 |
type: 'integer', |
| 32 |
minimum: 10, |
| 33 |
maximum: 300, |
| 34 |
description: |
| 35 |
'How many characters to quote either side of a match. Defaults to 60.', |
| 36 |
}, |
| 37 |
}, |
| 38 |
required: ['query'], |
| 39 |
}, |
| 40 |
annotations: { readonly: true }, |
| 41 |
execute: (input = {}) => apiFetch({ path, method: 'POST', data: input }), |
| 42 |
}; |
| 43 |
|