Skip to content

Commit 40a2e5d

Browse files
authored
docs: Update 3.search.md
1 parent f40e1a1 commit 40a2e5d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

docs/content/2.usage/3.search.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# Search
2-
3-
With some simple configuration and a composable, you can add search to your Nuxt Content site.
1+
---
2+
title: Search
3+
description: With some simple configuration and a composable, you can add search to your Nuxt Content site.
4+
---
45

56
## Usage
67

7-
First, you need to enable search in the `nuxt.config.js` file:
8+
First, you need to enable the search feature in your `nuxt.config.ts`:
89

9-
```js [nuxt.config.js]
10+
```js [nuxt.config.ts]
1011
export default defineNuxtConfig({
1112
content: {
1213
experimental: {
@@ -16,15 +17,15 @@ export default defineNuxtConfig({
1617
})
1718
```
1819

19-
::alert{type="info"}
20-
You can use the search feature with any [Nuxt Content source](/api/configuration#sources). You can also enable or not the [document-driven feature](/guide/writing/document-driven).
20+
::callout
21+
You can use the search feature with any [Nuxt Content source](/get-started/configuration#sources). You can also enable or not the [document-driven feature](/document-driven/introduction).
2122
::
2223

2324
## Search
2425

25-
You can use the `searchContent` composable to search in your `content` directory:
26+
You can use the [`searchContent`](/composables/search-content) composable to search in your `content` directory:
2627

27-
```vue
28+
```vue [app.vue]
2829
<script lang="ts" setup>
2930
const search = ref('')
3031
@@ -40,17 +41,17 @@ const results = searchContent(search)
4041
</template>
4142
```
4243

43-
By default, the `searchContent` composable will used an indexed search. This mean that the search will be faster and the API response smaller and optimized **only usable by [`miniSearch`](https://lucaong.github.io/minisearch/)**.
44+
By default, the [`searchContent`](/composables/search-content) composable will used an indexed search. This mean that the search will be faster and the API response smaller and optimized **only usable by [`miniSearch`](https://lucaong.github.io/minisearch/)**.
4445

45-
::alert{type="info"}
46+
::callout
4647
Internally, the search feature, both `searchContent` and `/api/indexed-search.ts` endpoint, use [`miniSearch`](https://lucaong.github.io/minisearch/).
4748
::
4849

4950
## Simple Search
5051

5152
If needed, you can disable the indexed search and use a simple search instead:
5253

53-
```js [nuxt.config.js]
54+
```ts [nuxt.config.ts]
5455
export default defineNuxtConfig({
5556
content: {
5657
experimental: {
@@ -68,7 +69,7 @@ Remember that the simple search is **slower** and the API response **bigger**. Y
6869

6970
Using the simple search, aka non-indexed search, you can use the tool of your choice to search in the API response. For example, you can use [`fuse.js`](https://fusejs.io/) with the integration of [`@vueuse/integrations`](https://vueuse.org/integrations/useFuse/#usefuse):
7071

71-
```ts
72+
```ts [composables/custom-search-content.ts]
7273
export default async function customSearchContent(search: Ref<string>) {
7374
const runtimeConfig = useRuntimeConfig()
7475
const { integrity, api } = runtimeConfig.public.content
@@ -83,4 +84,4 @@ export default async function customSearchContent(search: Ref<string>) {
8384

8485
## Configuration
8586

86-
Please, read the [configuration section](../../4.api/3.configuration.md#search) to learn more about the search configuration.
87+
Please, read the [configuration section](/get-started/configuration#search) to learn more about the search options.

0 commit comments

Comments
 (0)