Skip to content

Commit 2015920

Browse files
committed
docs: add reference examples to getSearchIndex
1 parent 7a61575 commit 2015920

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/next-drupal/src/next-drupal.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,19 @@ export class NextDrupal extends NextDrupalBase {
12231223
* @param {string} name The name of the search index.
12241224
* @param {JsonApiOptions & JsonApiWithNextFetchOptions} options Options for the request.
12251225
* @returns {Promise<T>} The fetched search index.
1226+
* @requires JSON:API Search API module
1227+
* @example
1228+
* Get search results from an index named `articles`
1229+
* ```ts
1230+
* const results = await drupal.getSearchIndex("articles")
1231+
* ```
1232+
*
1233+
* Using TypeScript with DrupalNode for a node entity type
1234+
* ```ts
1235+
* import { DrupalNode } from "next-drupal"
1236+
*
1237+
* const results = await drupal.getSearchIndex<DrupalNode>("articles")
1238+
* ```
12261239
*/
12271240
async getSearchIndex<T = JsonApiResource[]>(
12281241
name: string,

0 commit comments

Comments
 (0)