Skip to content

Commit ac61abe

Browse files
feat(search): upgrade search to DocSearch v4-beta (#4843)
BREAKING CHANGE: Uses DocSearch v4 beta. No change is required if you're not customizing the styles of navbar search button or modal. DocSearch AI features are in private beta, you can apply for them at https://forms.gle/iyfb5pC2CiiwszUKA --------- Co-authored-by: Divyansh Singh <[email protected]>
1 parent 3c51b22 commit ac61abe

30 files changed

+1510
-1427
lines changed

docs/.vitepress/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ export default defineConfig({
115115
options: {
116116
appId: '8J64VVRP8K',
117117
apiKey: '52f578a92b88ad6abde815aae2b0ad7c',
118-
indexName: 'vitepress'
118+
indexName: 'vitepress',
119+
askAi: 'YaVSonfX5bS8'
119120
}
120121
},
121122

docs/en/guide/getting-started.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ $ bun add -D vitepress
3939

4040
:::
4141

42-
::: details Getting missing peer deps warnings?
43-
If using PNPM, you will notice a missing peer warning for `@docsearch/js`. This does not prevent VitePress from working. If you wish to suppress this warning, add the following to your `package.json`:
44-
45-
```json
46-
"pnpm": {
47-
"peerDependencyRules": {
48-
"ignoreMissing": [
49-
"@algolia/client-search",
50-
"search-insights"
51-
]
52-
}
53-
}
54-
```
55-
56-
:::
57-
5842
::: tip NOTE
5943

6044
VitePress is an ESM-only package. Don't use `require()` to import it, and make sure your nearest `package.json` contains `"type": "module"`, or change the file extension of your relevant files like `.vitepress/config.js` to `.mjs`/`.mts`. Refer to [Vite's troubleshooting guide](http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only) for more details. Also, inside async CJS contexts, you can use `await import('vitepress')` instead.

docs/en/reference/default-theme-search.md

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,34 +233,65 @@ export default defineConfig({
233233
},
234234
modal: {
235235
searchBox: {
236-
resetButtonTitle: '清除查询条件',
237-
resetButtonAriaLabel: '清除查询条件',
238-
cancelButtonText: '取消',
239-
cancelButtonAriaLabel: '取消'
236+
clearButtonTitle: '清除查询条件',
237+
clearButtonAriaLabel: '清除查询条件',
238+
closeButtonText: '关闭',
239+
closeButtonAriaLabel: '关闭',
240+
placeholderText: '搜索文档',
241+
placeholderTextAskAi: '向 AI 提问:',
242+
placeholderTextAskAiStreaming: '回答中...',
243+
searchInputLabel: '搜索',
244+
backToKeywordSearchButtonText: '返回关键字搜索',
245+
backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
240246
},
241247
startScreen: {
242248
recentSearchesTitle: '搜索历史',
243249
noRecentSearchesText: '没有搜索历史',
244250
saveRecentSearchButtonTitle: '保存至搜索历史',
245251
removeRecentSearchButtonTitle: '从搜索历史中移除',
246252
favoriteSearchesTitle: '收藏',
247-
removeFavoriteSearchButtonTitle: '从收藏中移除'
253+
removeFavoriteSearchButtonTitle: '从收藏中移除',
254+
recentConversationsTitle: '最近的对话',
255+
removeRecentConversationButtonTitle: '从历史记录中删除对话'
248256
},
249257
errorScreen: {
250258
titleText: '无法获取结果',
251259
helpText: '你可能需要检查你的网络连接'
252260
},
253-
footer: {
254-
selectText: '选择',
255-
navigateText: '切换',
256-
closeText: '关闭',
257-
searchByText: '搜索提供者'
258-
},
259261
noResultsScreen: {
260262
noResultsText: '无法找到相关结果',
261263
suggestedQueryText: '你可以尝试查询',
262264
reportMissingResultsText: '你认为该查询应该有结果?',
263265
reportMissingResultsLinkText: '点击反馈'
266+
},
267+
resultsScreen: {
268+
askAiPlaceholder: '向 AI 提问: '
269+
},
270+
askAiScreen: {
271+
disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
272+
relatedSourcesText: '相关来源',
273+
thinkingText: '思考中...',
274+
copyButtonText: '复制',
275+
copyButtonCopiedText: '已复制!',
276+
copyButtonTitle: '复制',
277+
likeButtonTitle: '',
278+
dislikeButtonTitle: '',
279+
thanksForFeedbackText: '感谢你的反馈!',
280+
preToolCallText: '搜索中...',
281+
duringToolCallText: '搜索 ',
282+
afterToolCallText: '已搜索'
283+
},
284+
footer: {
285+
selectText: '选择',
286+
submitQuestionText: '提交问题',
287+
selectKeyAriaLabel: 'Enter 键',
288+
navigateText: '切换',
289+
navigateUpKeyAriaLabel: '向上箭头',
290+
navigateDownKeyAriaLabel: '向下箭头',
291+
closeText: '关闭',
292+
backToSearchText: '返回搜索',
293+
closeKeyAriaLabel: 'Esc 键',
294+
poweredByText: '搜索提供者'
264295
}
265296
}
266297
}
@@ -274,6 +305,43 @@ export default defineConfig({
274305

275306
[These options](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) can be overridden. Refer official Algolia docs to learn more about them.
276307

308+
### Algolia Ask AI Support {#ask-ai}
309+
310+
If you would like to include **Ask AI**, pass the `askAi` option (or any of the partial fields) inside `options`:
311+
312+
```ts
313+
import { defineConfig } from 'vitepress'
314+
315+
export default defineConfig({
316+
themeConfig: {
317+
search: {
318+
provider: 'algolia',
319+
options: {
320+
appId: '...',
321+
apiKey: '...',
322+
indexName: '...',
323+
// askAi: "YOUR-ASSISTANT-ID"
324+
// OR
325+
askAi: {
326+
// at minimum you must provide the assistantId you received from Algolia
327+
assistantId: 'XXXYYY',
328+
// optional overrides – if omitted, the top-level appId/apiKey/indexName values are reused
329+
// apiKey: '...',
330+
// appId: '...',
331+
// indexName: '...'
332+
}
333+
}
334+
}
335+
}
336+
})
337+
```
338+
339+
::: warning Note
340+
If want to default to keyword search and do not want to use Ask AI, just omit the `askAi` property
341+
:::
342+
343+
The translations for the Ask AI UI live under `options.translations.modal.askAiScreen` and `options.translations.resultsScreen` — see the [type definitions](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) for all keys.
344+
277345
### Crawler Config
278346

279347
Here is an example config based on what this site uses:

docs/es/config.ts

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,35 +186,70 @@ function searchOptions(): Partial<DefaultTheme.AlgoliaSearchOptions> {
186186
},
187187
modal: {
188188
searchBox: {
189-
resetButtonTitle: 'Limpiar búsqueda',
190-
resetButtonAriaLabel: 'Limpiar búsqueda',
191-
cancelButtonText: 'Cancelar',
192-
cancelButtonAriaLabel: 'Cancelar'
189+
clearButtonTitle: 'Limpiar búsqueda',
190+
clearButtonAriaLabel: 'Limpiar búsqueda',
191+
closeButtonText: 'Cerrar',
192+
closeButtonAriaLabel: 'Cerrar',
193+
placeholderText: undefined,
194+
placeholderTextAskAi: undefined,
195+
placeholderTextAskAiStreaming: 'Respondiendo...',
196+
backToKeywordSearchButtonText:
197+
'Volver a la búsqueda por palabras clave',
198+
backToKeywordSearchButtonAriaLabel:
199+
'Volver a la búsqueda por palabras clave'
193200
},
194201
startScreen: {
195202
recentSearchesTitle: 'Historial de búsqueda',
196203
noRecentSearchesText: 'Ninguna búsqueda reciente',
197204
saveRecentSearchButtonTitle: 'Guardar en el historial de búsqueda',
198205
removeRecentSearchButtonTitle: 'Borrar del historial de búsqueda',
199206
favoriteSearchesTitle: 'Favoritos',
200-
removeFavoriteSearchButtonTitle: 'Borrar de favoritos'
207+
removeFavoriteSearchButtonTitle: 'Borrar de favoritos',
208+
recentConversationsTitle: 'Conversaciones recientes',
209+
removeRecentConversationButtonTitle:
210+
'Eliminar esta conversación del historial'
201211
},
202212
errorScreen: {
203213
titleText: 'No fue posible obtener resultados',
204214
helpText: 'Verifique su conexión de red'
205215
},
206-
footer: {
207-
selectText: 'Seleccionar',
208-
navigateText: 'Navegar',
209-
closeText: 'Cerrar',
210-
searchByText: 'Busqueda por'
211-
},
212216
noResultsScreen: {
213217
noResultsText: 'No fue posible encontrar resultados',
214218
suggestedQueryText: 'Puede intentar una nueva búsqueda',
215219
reportMissingResultsText:
216-
'Deberian haber resultados para esa consulta?',
220+
'¿Deberían haber resultados para esta consulta?',
217221
reportMissingResultsLinkText: 'Click para enviar feedback'
222+
},
223+
resultsScreen: {
224+
askAiPlaceholder: 'Preguntar a la IA: '
225+
},
226+
askAiScreen: {
227+
disclaimerText:
228+
'Las respuestas son generadas por IA y pueden contener errores. Verifica las respuestas.',
229+
relatedSourcesText: 'Fuentes relacionadas',
230+
thinkingText: 'Pensando...',
231+
copyButtonText: 'Copiar',
232+
copyButtonCopiedText: '¡Copiado!',
233+
copyButtonTitle: 'Copiar',
234+
likeButtonTitle: 'Me gusta',
235+
dislikeButtonTitle: 'No me gusta',
236+
thanksForFeedbackText: '¡Gracias por tu opinión!',
237+
preToolCallText: 'Buscando...',
238+
duringToolCallText: 'Buscando ',
239+
afterToolCallText: 'Búsqueda de',
240+
aggregatedToolCallText: 'Búsqueda de'
241+
},
242+
footer: {
243+
selectText: 'Seleccionar',
244+
submitQuestionText: 'Enviar pregunta',
245+
selectKeyAriaLabel: 'Tecla Enter',
246+
navigateText: 'Navegar',
247+
navigateUpKeyAriaLabel: 'Flecha arriba',
248+
navigateDownKeyAriaLabel: 'Flecha abajo',
249+
closeText: 'Cerrar',
250+
backToSearchText: 'Volver a la búsqueda',
251+
closeKeyAriaLabel: 'Tecla Escape',
252+
poweredByText: 'Búsqueda por'
218253
}
219254
}
220255
}

docs/es/guide/getting-started.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@ $ bun add -D vitepress
3535

3636
:::
3737

38-
::: details Recibiendo avisos sobre dependencias ausentes?
39-
Si usa PNPM, percibirá un aviso de ausencia de `@docsearch/js`. Esto no evita que VitePress funcione. Si desea eliminar este aviso, adicione lo siguiente en su `package.json`:
40-
41-
```json
42-
"pnpm": {
43-
"peerDependencyRules": {
44-
"ignoreMissing": [
45-
"@algolia/client-search",
46-
"search-insights"
47-
]
48-
}
49-
}
50-
```
51-
52-
:::
53-
5438
::: tip NOTA
5539

5640
VitePress es un paquete apenas para ESM. No use `require()` para importarlo, y asegurese de que el `package.json` más cercano contiene `"type": "module"`, o cambie la extensión de archivo de sus archivos relevantes como `.vitepress/config.js` a `.mjs`/`.mts`. Consulte la [Guía de resolución de problemas Vite](http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only) para más detalles. Además de eso, dentro de contextos de JavaScript asíncronos, puede usar `await import('vitepress')`.

docs/es/reference/default-theme-search.md

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,40 +216,66 @@ export default defineConfig({
216216
zh: {
217217
placeholder: '搜索文档',
218218
translations: {
219-
button: {
220-
buttonText: '搜索文档',
221-
buttonAriaLabel: '搜索文档'
222-
},
219+
button: { buttonText: '搜索文档', buttonAriaLabel: '搜索文档' },
223220
modal: {
224221
searchBox: {
225-
resetButtonTitle: '清除查询条件',
226-
resetButtonAriaLabel: '清除查询条件',
227-
cancelButtonText: '取消',
228-
cancelButtonAriaLabel: '取消'
222+
clearButtonTitle: '清除查询条件',
223+
clearButtonAriaLabel: '清除查询条件',
224+
closeButtonText: '关闭',
225+
closeButtonAriaLabel: '关闭',
226+
placeholderText: '搜索文档',
227+
placeholderTextAskAi: '向 AI 提问:',
228+
placeholderTextAskAiStreaming: '回答中...',
229+
searchInputLabel: '搜索',
230+
backToKeywordSearchButtonText: '返回关键字搜索',
231+
backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
229232
},
230233
startScreen: {
231234
recentSearchesTitle: '搜索历史',
232235
noRecentSearchesText: '没有搜索历史',
233236
saveRecentSearchButtonTitle: '保存至搜索历史',
234237
removeRecentSearchButtonTitle: '从搜索历史中移除',
235238
favoriteSearchesTitle: '收藏',
236-
removeFavoriteSearchButtonTitle: '从收藏中移除'
239+
removeFavoriteSearchButtonTitle: '从收藏中移除',
240+
recentConversationsTitle: '最近的对话',
241+
removeRecentConversationButtonTitle: '从历史记录中删除对话'
237242
},
238243
errorScreen: {
239244
titleText: '无法获取结果',
240245
helpText: '你可能需要检查你的网络连接'
241246
},
242-
footer: {
243-
selectText: '选择',
244-
navigateText: '切换',
245-
closeText: '关闭',
246-
searchByText: '搜索提供者'
247-
},
248247
noResultsScreen: {
249248
noResultsText: '无法找到相关结果',
250249
suggestedQueryText: '你可以尝试查询',
251250
reportMissingResultsText: '你认为该查询应该有结果?',
252251
reportMissingResultsLinkText: '点击反馈'
252+
},
253+
resultsScreen: { askAiPlaceholder: '向 AI 提问: ' },
254+
askAiScreen: {
255+
disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
256+
relatedSourcesText: '相关来源',
257+
thinkingText: '思考中...',
258+
copyButtonText: '复制',
259+
copyButtonCopiedText: '已复制!',
260+
copyButtonTitle: '复制',
261+
likeButtonTitle: '',
262+
dislikeButtonTitle: '',
263+
thanksForFeedbackText: '感谢你的反馈!',
264+
preToolCallText: '搜索中...',
265+
duringToolCallText: '搜索 ',
266+
afterToolCallText: '已搜索'
267+
},
268+
footer: {
269+
selectText: '选择',
270+
submitQuestionText: '提交问题',
271+
selectKeyAriaLabel: 'Enter 键',
272+
navigateText: '切换',
273+
navigateUpKeyAriaLabel: '向上箭头',
274+
navigateDownKeyAriaLabel: '向下箭头',
275+
closeText: '关闭',
276+
backToSearchText: '返回搜索',
277+
closeKeyAriaLabel: 'Esc 键',
278+
poweredByText: '搜索提供者'
253279
}
254280
}
255281
}
@@ -261,6 +287,26 @@ export default defineConfig({
261287
})
262288
```
263289

290+
### Algolia Ask AI Support {#ask-ai}
291+
292+
Si deseas incluir **Ask AI**, pasa la opción `askAi` (o alguno de sus campos parciales) dentro de `options`:
293+
294+
```ts
295+
options: {
296+
appId: '...',
297+
apiKey: '...',
298+
indexName: '...',
299+
// askAi: 'TU-ASSISTANT-ID'
300+
askAi: {
301+
assistantId: 'XXXYYY'
302+
}
303+
}
304+
```
305+
306+
::: warning Nota
307+
Si prefieres solo la búsqueda por palabra clave y no la Ask AI, simplemente omite `askAi`.
308+
:::
309+
264310
[Estas opciones](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) se pueden superponer. Consulte la documentación oficial de Algolia para obtener más información sobre ellos.
265311

266312
### Configuración _Crawler_ {#crawler-config}

0 commit comments

Comments
 (0)