From 68b39d366ebcfe7fdf6fcac256dd3b5c39b4d0d8 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sat, 31 Jan 2026 02:32:02 +0530
Subject: [PATCH] update docs
---
docs/en/reference/default-theme-search.md | 206 +--------------------
docs/es/reference/default-theme-search.md | 205 ++-------------------
docs/fa/reference/default-theme-search.md | 185 ++-----------------
docs/ja/reference/default-theme-search.md | 210 +---------------------
docs/ko/reference/default-theme-search.md | 187 ++-----------------
docs/pt/reference/default-theme-search.md | 187 ++-----------------
docs/ru/reference/default-theme-search.md | 210 +---------------------
docs/snippets/algolia-crawler.js | 101 +++++++++++
docs/snippets/algolia-i18n.ts | 155 ++++++++++++++++
docs/zh/reference/default-theme-search.md | 205 ++-------------------
10 files changed, 340 insertions(+), 1511 deletions(-)
create mode 100644 docs/snippets/algolia-crawler.js
create mode 100644 docs/snippets/algolia-i18n.ts
diff --git a/docs/en/reference/default-theme-search.md b/docs/en/reference/default-theme-search.md
index 72e77369..8221bb4a 100644
--- a/docs/en/reference/default-theme-search.md
+++ b/docs/en/reference/default-theme-search.md
@@ -213,98 +213,14 @@ export default defineConfig({
You can use a config like this to use multilingual search:
-```ts
-import { defineConfig } from 'vitepress'
+
+View full example
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: {
- buttonText: '搜索文档',
- buttonAriaLabel: '搜索文档'
- },
- modal: {
- searchBox: {
- clearButtonTitle: '清除查询条件',
- clearButtonAriaLabel: '清除查询条件',
- closeButtonText: '关闭',
- closeButtonAriaLabel: '关闭',
- placeholderText: '搜索文档',
- placeholderTextAskAi: '向 AI 提问:',
- placeholderTextAskAiStreaming: '回答中...',
- searchInputLabel: '搜索',
- backToKeywordSearchButtonText: '返回关键字搜索',
- backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
- },
- startScreen: {
- recentSearchesTitle: '搜索历史',
- noRecentSearchesText: '没有搜索历史',
- saveRecentSearchButtonTitle: '保存至搜索历史',
- removeRecentSearchButtonTitle: '从搜索历史中移除',
- favoriteSearchesTitle: '收藏',
- removeFavoriteSearchButtonTitle: '从收藏中移除',
- recentConversationsTitle: '最近的对话',
- removeRecentConversationButtonTitle: '从历史记录中删除对话'
- },
- errorScreen: {
- titleText: '无法获取结果',
- helpText: '你可能需要检查你的网络连接'
- },
- noResultsScreen: {
- noResultsText: '无法找到相关结果',
- suggestedQueryText: '你可以尝试查询',
- reportMissingResultsText: '你认为该查询应该有结果?',
- reportMissingResultsLinkText: '点击反馈'
- },
- resultsScreen: {
- askAiPlaceholder: '向 AI 提问: '
- },
- askAiScreen: {
- disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
- relatedSourcesText: '相关来源',
- thinkingText: '思考中...',
- copyButtonText: '复制',
- copyButtonCopiedText: '已复制!',
- copyButtonTitle: '复制',
- likeButtonTitle: '赞',
- dislikeButtonTitle: '踩',
- thanksForFeedbackText: '感谢你的反馈!',
- preToolCallText: '搜索中...',
- duringToolCallText: '搜索 ',
- afterToolCallText: '已搜索'
- },
- footer: {
- selectText: '选择',
- submitQuestionText: '提交问题',
- selectKeyAriaLabel: 'Enter 键',
- navigateText: '切换',
- navigateUpKeyAriaLabel: '向上箭头',
- navigateDownKeyAriaLabel: '向下箭头',
- closeText: '关闭',
- backToSearchText: '返回搜索',
- closeKeyAriaLabel: 'Esc 键',
- poweredByText: '搜索提供者'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
-[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.
+
+
+Refer [official Algolia docs](https://docsearch.algolia.com/docs/api#translations) to learn more about them. To quickly get started, you can also copy the translations used by this site from [our GitHub repo](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code).
### Algolia Ask AI Support {#ask-ai}
@@ -341,8 +257,6 @@ export default defineConfig({
If you want to default to keyword search and do not want to use Ask AI, omit the `askAi` property.
:::
-The translations for Ask AI inside the **modal** live under `options.translations.modal.askAiScreen` and `options.translations.modal.resultsScreen` — see the [type definitions](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) for all keys.
-
### Ask AI Side Panel {#ask-ai-side-panel}
DocSearch v4.5+ supports an optional **Ask AI side panel**. When enabled, it can be opened with **Ctrl/Cmd+I** by default. The [Sidepanel API Reference](https://docsearch.algolia.com/docs/sidepanel/api-reference) contains the full list of options.
@@ -403,10 +317,6 @@ export default defineConfig({
})
```
-#### Side panel i18n
-
-Side panel translations are configured under `options.askAi.sidePanel.panel.translations`. Refer to the [type definitions](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) for the full shape.
-
#### Mode (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
You can optionally control how VitePress integrates keyword search and Ask AI:
@@ -446,106 +356,4 @@ export default defineConfig({
Here is an example config based on what this site uses:
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/es/reference/default-theme-search.md b/docs/es/reference/default-theme-search.md
index 995c079f..26a8b856 100644
--- a/docs/es/reference/default-theme-search.md
+++ b/docs/es/reference/default-theme-search.md
@@ -201,91 +201,14 @@ export default defineConfig({
Puedes utilizar una configuración como esta para utilizar la búsqueda multilingüe:
-```ts
-import { defineConfig } from 'vitepress'
+
+Haz clic para expandir
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: { buttonText: '搜索文档', buttonAriaLabel: '搜索文档' },
- modal: {
- searchBox: {
- clearButtonTitle: '清除查询条件',
- clearButtonAriaLabel: '清除查询条件',
- closeButtonText: '关闭',
- closeButtonAriaLabel: '关闭',
- placeholderText: '搜索文档',
- placeholderTextAskAi: '向 AI 提问:',
- placeholderTextAskAiStreaming: '回答中...',
- searchInputLabel: '搜索',
- backToKeywordSearchButtonText: '返回关键字搜索',
- backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
- },
- startScreen: {
- recentSearchesTitle: '搜索历史',
- noRecentSearchesText: '没有搜索历史',
- saveRecentSearchButtonTitle: '保存至搜索历史',
- removeRecentSearchButtonTitle: '从搜索历史中移除',
- favoriteSearchesTitle: '收藏',
- removeFavoriteSearchButtonTitle: '从收藏中移除',
- recentConversationsTitle: '最近的对话',
- removeRecentConversationButtonTitle: '从历史记录中删除对话'
- },
- errorScreen: {
- titleText: '无法获取结果',
- helpText: '你可能需要检查你的网络连接'
- },
- noResultsScreen: {
- noResultsText: '无法找到相关结果',
- suggestedQueryText: '你可以尝试查询',
- reportMissingResultsText: '你认为该查询应该有结果?',
- reportMissingResultsLinkText: '点击反馈'
- },
- resultsScreen: { askAiPlaceholder: '向 AI 提问: ' },
- askAiScreen: {
- disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
- relatedSourcesText: '相关来源',
- thinkingText: '思考中...',
- copyButtonText: '复制',
- copyButtonCopiedText: '已复制!',
- copyButtonTitle: '复制',
- likeButtonTitle: '赞',
- dislikeButtonTitle: '踩',
- thanksForFeedbackText: '感谢你的反馈!',
- preToolCallText: '搜索中...',
- duringToolCallText: '搜索 ',
- afterToolCallText: '已搜索'
- },
- footer: {
- selectText: '选择',
- submitQuestionText: '提交问题',
- selectKeyAriaLabel: 'Enter 键',
- navigateText: '切换',
- navigateUpKeyAriaLabel: '向上箭头',
- navigateDownKeyAriaLabel: '向下箭头',
- closeText: '关闭',
- backToSearchText: '返回搜索',
- closeKeyAriaLabel: 'Esc 键',
- poweredByText: '搜索提供者'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
+
+
+
+Consulta la [documentación oficial de Algolia](https://docsearch.algolia.com/docs/api#translations) para conocer más detalles. Para empezar rápidamente, también puedes copiar las traducciones usadas por este sitio desde [nuestro repositorio de GitHub](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code).
### Algolia Ask AI Support {#ask-ai}
@@ -307,8 +230,6 @@ options: {
Si prefieres solo la búsqueda por palabra clave y no la Ask AI, simplemente omite `askAi`.
:::
-Las traducciones para Ask AI dentro del **modal** se encuentran en `options.translations.modal.askAiScreen` y `options.translations.modal.resultsScreen` — consulta las [definiciones de tipos](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) para todas las claves.
-
### Panel lateral de Ask AI {#ask-ai-side-panel}
DocSearch v4.5+ admite un **panel lateral de Ask AI** opcional. Cuando está habilitado, se puede abrir con **Ctrl/Cmd+I** por defecto. La [Referencia de API del Panel Lateral](https://docsearch.algolia.com/docs/sidepanel/api-reference) contiene la lista completa de opciones.
@@ -370,11 +291,7 @@ export default defineConfig({
})
```
-#### i18n del panel lateral
-
-Las traducciones del panel lateral se configuran bajo `options.askAi.sidePanel.panel.translations`. Consulta las [definiciones de tipos](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) para la estructura completa.
-
-### Modo (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### Modo (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
Puedes controlar opcionalmente cómo VitePress integra la búsqueda por palabra clave y Ask AI:
@@ -383,7 +300,7 @@ Puedes controlar opcionalmente cómo VitePress integra la búsqueda por palabra
- `mode: 'hybrid'`: habilita el modal de búsqueda por palabra clave + panel lateral de Ask AI (requiere configuración de búsqueda por palabra clave).
- `mode: 'modal'`: mantiene Ask AI dentro del modal de DocSearch (incluso si configuraste el panel lateral).
-### Solo Ask AI (sin búsqueda por palabra clave) {#ask-ai-only}
+#### Solo Ask AI (sin búsqueda por palabra clave) {#ask-ai-only}
Si quieres usar **solo el panel lateral de Ask AI**, puedes omitir la configuración de búsqueda por palabra clave de nivel superior y proporcionar las credenciales bajo `askAi`:
@@ -413,106 +330,4 @@ export default defineConfig({
A continuación se muestra un ejemplo de la configuración que utiliza este sitio:
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/fa/reference/default-theme-search.md b/docs/fa/reference/default-theme-search.md
index 2dff22f1..e5adee7d 100644
--- a/docs/fa/reference/default-theme-search.md
+++ b/docs/fa/reference/default-theme-search.md
@@ -208,173 +208,14 @@ export default defineConfig({
میتوانید با استفاده از تنظیماتی مانند این برای جستجوی چندزبانه استفاده کنید:
-```ts
-import { defineConfig } from 'vitepress'
-
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: {
- buttonText: '搜索文档',
- buttonAriaLabel: '搜索文档'
- },
- modal: {
- searchBox: {
- resetButtonTitle: '清除搜索条件',
- resetButtonAriaLabel: '清除搜索条件',
- cancelButtonText: '取消',
- cancelButtonAriaLabel: '取消'
- },
- startScreen: {
- recentSearchesTitle: '最近搜索',
- noRecentSearchesText: '没有最近搜索',
- saveRecentSearchButtonTitle: '保存到最近搜索',
- removeRecentSearchButtonTitle: '从最近搜索中删除'
- },
- errorScreen: {
- titleText: '无法显示结果',
- helpText: '您可能需要检查您的互联网连接'
- },
- footer: {
- selectText: '选择',
- navigateText: '导航',
- closeText: '关闭',
- searchByText: '搜索由'
- },
- noResultsScreen: {
- noResultsText: '没有找到结果',
- suggestedQueryText: '您可以尝试',
- reportMissingResultsText: '您认为应该有结果吗?',
- reportMissingResultsLinkText: '点击这里报告'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+
+برای باز کردن کلیک کنید
-این [گزینهها](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) میتوانند بازنویسی شوند. برای یادگیری بیشتر درباره آنها به اسناد رسمی Algolia مراجعه کنید.
+<<< @/snippets/algolia-i18n.ts
-### پیکربندی Crawler {#crawler-config}
-
-در اینجا یک پیکربندی نمونه بر اساس آنچه که این سایت استفاده میکند آمده است:
+
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: '',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+برای اطلاعات بیشتر به [مستندات رسمی Algolia](https://docsearch.algolia.com/docs/api#translations) مراجعه کنید. برای شروع سریعتر، میتوانید ترجمههای استفادهشده در این سایت را از [مخزن GitHub ما](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code) کپی کنید.
### پشتیبانی Algolia Ask AI {#ask-ai}
@@ -395,8 +236,6 @@ options: {
اگر فقط به جستجوی کلمات کلیدی نیاز دارید، `askAi` را اضافه نکنید.
:::
-ترجمههای Ask AI درون **مودال** در `options.translations.modal.askAiScreen` و `options.translations.modal.resultsScreen` قرار دارند — برای تمام کلیدها به [تعاریف نوع](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) مراجعه کنید.
-
### پنل کناری Ask AI {#ask-ai-side-panel}
DocSearch v4.5+ از **پنل کناری Ask AI** اختیاری پشتیبانی میکند. وقتی فعال باشد، به طور پیشفرض میتوان آن را با **Ctrl/Cmd+I** باز کرد. [مرجع API پنل کناری](https://docsearch.algolia.com/docs/sidepanel/api-reference) شامل لیست کامل گزینهها است.
@@ -458,11 +297,7 @@ export default defineConfig({
})
```
-#### i18n پنل کناری
-
-ترجمههای پنل کناری در `options.askAi.sidePanel.panel.translations` پیکربندی میشوند. برای ساختار کامل به [تعاریف نوع](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) مراجعه کنید.
-
-### حالت (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### حالت (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
میتوانید به صورت اختیاری نحوه ادغام جستجوی کلمات کلیدی و Ask AI در VitePress را کنترل کنید:
@@ -471,7 +306,7 @@ export default defineConfig({
- `mode: 'hybrid'`: مودال جستجوی کلمات کلیدی + پنل کناری Ask AI را فعال میکند (نیاز به پیکربندی جستجوی کلمات کلیدی دارد).
- `mode: 'modal'`: Ask AI را درون مودال DocSearch نگه میدارد (حتی اگر پنل کناری را پیکربندی کرده باشید).
-### فقط Ask AI (بدون جستجوی کلمات کلیدی) {#ask-ai-only}
+#### فقط Ask AI (بدون جستجوی کلمات کلیدی) {#ask-ai-only}
اگر میخواهید **فقط پنل کناری Ask AI** را استفاده کنید، میتوانید پیکربندی جستجوی کلمات کلیدی سطح بالا را حذف کرده و اعتبارنامهها را در `askAi` ارائه دهید:
@@ -496,3 +331,9 @@ export default defineConfig({
}
})
```
+
+### پیکربندی Crawler {#crawler-config}
+
+در اینجا یک پیکربندی نمونه بر اساس آنچه که این سایت استفاده میکند آمده است:
+
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/ja/reference/default-theme-search.md b/docs/ja/reference/default-theme-search.md
index 3329ffe0..387f7688 100644
--- a/docs/ja/reference/default-theme-search.md
+++ b/docs/ja/reference/default-theme-search.md
@@ -212,98 +212,14 @@ export default defineConfig({
多言語検索の設定例です。
-```ts
-import { defineConfig } from 'vitepress'
+
+クリックして展開
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: {
- buttonText: '搜索文档',
- buttonAriaLabel: '搜索文档'
- },
- modal: {
- searchBox: {
- clearButtonTitle: '清除查询条件',
- clearButtonAriaLabel: '清除查询条件',
- closeButtonText: '关闭',
- closeButtonAriaLabel: '关闭',
- placeholderText: '搜索文档',
- placeholderTextAskAi: '向 AI 提问:',
- placeholderTextAskAiStreaming: '回答中...',
- searchInputLabel: '搜索',
- backToKeywordSearchButtonText: '返回关键字搜索',
- backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
- },
- startScreen: {
- recentSearchesTitle: '搜索历史',
- noRecentSearchesText: '没有搜索历史',
- saveRecentSearchButtonTitle: '保存至搜索历史',
- removeRecentSearchButtonTitle: '从搜索历史中移除',
- favoriteSearchesTitle: '收藏',
- removeFavoriteSearchButtonTitle: '从收藏中移除',
- recentConversationsTitle: '最近的对话',
- removeRecentConversationButtonTitle: '从历史记录中删除对话'
- },
- errorScreen: {
- titleText: '无法获取结果',
- helpText: '你可能需要检查你的网络连接'
- },
- noResultsScreen: {
- noResultsText: '无法找到相关结果',
- suggestedQueryText: '你可以尝试查询',
- reportMissingResultsText: '你认为该查询应该有结果?',
- reportMissingResultsLinkText: '点击反馈'
- },
- resultsScreen: {
- askAiPlaceholder: '向 AI 提问: '
- },
- askAiScreen: {
- disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
- relatedSourcesText: '相关来源',
- thinkingText: '思考中...',
- copyButtonText: '复制',
- copyButtonCopiedText: '已复制!',
- copyButtonTitle: '复制',
- likeButtonTitle: '赞',
- dislikeButtonTitle: '踩',
- thanksForFeedbackText: '感谢你的反馈!',
- preToolCallText: '搜索中...',
- duringToolCallText: '搜索 ',
- afterToolCallText: '已搜索'
- },
- footer: {
- selectText: '选择',
- submitQuestionText: '提交问题',
- selectKeyAriaLabel: 'Enter 键',
- navigateText: '切换',
- navigateUpKeyAriaLabel: '向上箭头',
- navigateDownKeyAriaLabel: '向下箭头',
- closeText: '关闭',
- backToSearchText: '返回搜索',
- closeKeyAriaLabel: 'Esc 键',
- poweredByText: '搜索提供者'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
-[これらのオプション](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) は上書きできます。詳細は Algolia の公式ドキュメントを参照してください。
+
+
+詳しくは[公式 Algolia ドキュメント](https://docsearch.algolia.com/docs/api#translations)を参照してください。すぐに始めるには、このサイトで使っている翻訳を[GitHub リポジトリ](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code)からコピーすることもできます。
### Algolia Ask AI のサポート {#ask-ai}
@@ -340,8 +256,6 @@ export default defineConfig({
キーワード検索を既定にして Ask AI を使わない場合は、`askAi` を指定しないでください。
:::
-**モーダル**内の Ask AI の翻訳は `options.translations.modal.askAiScreen` と `options.translations.modal.resultsScreen` にあります。すべてのキーは[型定義](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)を参照してください。
-
### Ask AI サイドパネル {#ask-ai-side-panel}
DocSearch v4.5+ はオプションの **Ask AI サイドパネル**をサポートしています。有効にすると、デフォルトで **Ctrl/Cmd+I** で開くことができます。[サイドパネル API リファレンス](https://docsearch.algolia.com/docs/sidepanel/api-reference)にオプションの完全なリストがあります。
@@ -403,11 +317,7 @@ export default defineConfig({
})
```
-#### サイドパネルの i18n
-
-サイドパネルの翻訳は `options.askAi.sidePanel.panel.translations` の下で設定されます。完全な構造については[型定義](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)を参照してください。
-
-### モード (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### モード (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
VitePress がキーワード検索と Ask AI を統合する方法をオプションで制御できます:
@@ -416,7 +326,7 @@ VitePress がキーワード検索と Ask AI を統合する方法をオプシ
- `mode: 'hybrid'`:キーワード検索モーダル + Ask AI サイドパネルを有効化(キーワード検索設定が必要)。
- `mode: 'modal'`:Ask AI を DocSearch モーダル内に保持(サイドパネルを設定した場合でも)。
-### Ask AI のみ(キーワード検索なし) {#ask-ai-only}
+#### Ask AI のみ(キーワード検索なし) {#ask-ai-only}
**Ask AI サイドパネルのみ**を使用する場合は、トップレベルのキーワード検索設定を省略し、`askAi` の下に認証情報を提供できます:
@@ -446,106 +356,4 @@ export default defineConfig({
このサイトで使用している設定を元にした例です。
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/ko/reference/default-theme-search.md b/docs/ko/reference/default-theme-search.md
index 52ac308e..35e8b66c 100644
--- a/docs/ko/reference/default-theme-search.md
+++ b/docs/ko/reference/default-theme-search.md
@@ -208,175 +208,14 @@ export default defineConfig({
다국어 검색을 사용하려면 다음과 같이 구성해야 합니다:
-```ts
-import { defineConfig } from 'vitepress'
+
+클릭하여 펼치기
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- ko: {
- placeholder: '문서 검색',
- translations: {
- button: {
- buttonText: '검색',
- buttonAriaLabel: '검색'
- },
- modal: {
- searchBox: {
- resetButtonTitle: '검색 지우기',
- resetButtonAriaLabel: '검색 지우기',
- cancelButtonText: '취소',
- cancelButtonAriaLabel: '취소'
- },
- startScreen: {
- recentSearchesTitle: '검색 기록',
- noRecentSearchesText: '최근 검색 없음',
- saveRecentSearchButtonTitle: '검색 기록에 저장',
- removeRecentSearchButtonTitle: '검색 기록에서 삭제',
- favoriteSearchesTitle: '즐겨찾기',
- removeFavoriteSearchButtonTitle: '즐겨찾기에서 삭제'
- },
- errorScreen: {
- titleText: '결과를 가져올 수 없습니다',
- helpText: '네트워크 연결을 확인하세요'
- },
- footer: {
- selectText: '선택',
- navigateText: '탐색',
- closeText: '닫기',
- searchByText: '검색 기준'
- },
- noResultsScreen: {
- noResultsText: '결과를 찾을 수 없습니다',
- suggestedQueryText: '새로운 검색을 시도할 수 있습니다',
- reportMissingResultsText: '해당 검색어에 대한 결과가 있어야 합니까?',
- reportMissingResultsLinkText: '피드백 보내기 클릭'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
-[이 옵션들](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)은 재작성 할 수 있습니다. 이에 대해 자세히 알고 싶다면 Algolia 공식 문서를 참고하세요.
+
-### 크롤러 구성 {#crawler-config}
-
-이 사이트에서 사용하는 예제 구성을 소개합니다:
-
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+자세한 내용은 [공식 Algolia 문서](https://docsearch.algolia.com/docs/api#translations)를 참고하세요. 빠르게 시작하려면 이 사이트에서 사용하는 번역을 [GitHub 저장소](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code)에서 복사할 수도 있습니다.
### Algolia Ask AI 지원 {#ask-ai}
@@ -395,8 +234,6 @@ options: {
Ask AI를 사용하지 않으려면 `askAi` 옵션을 생략하면 됩니다.
:::
-**모달** 내부의 Ask AI 번역은 `options.translations.modal.askAiScreen`과 `options.translations.modal.resultsScreen`에 있습니다. 모든 키는 [타입 정의](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)를 참조하세요.
-
### Ask AI 사이드 패널 {#ask-ai-side-panel}
DocSearch v4.5+는 선택적 **Ask AI 사이드 패널**을 지원합니다. 활성화되면 기본적으로 **Ctrl/Cmd+I**로 열 수 있습니다. [사이드 패널 API 참조](https://docsearch.algolia.com/docs/sidepanel/api-reference)에 전체 옵션 목록이 있습니다.
@@ -458,11 +295,7 @@ export default defineConfig({
})
```
-#### 사이드 패널 i18n
-
-사이드 패널 번역은 `options.askAi.sidePanel.panel.translations` 아래에서 구성됩니다. 전체 구조는 [타입 정의](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)를 참조하세요.
-
-### 모드 (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### 모드 (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
VitePress가 키워드 검색과 Ask AI를 통합하는 방식을 선택적으로 제어할 수 있습니다:
@@ -471,7 +304,7 @@ VitePress가 키워드 검색과 Ask AI를 통합하는 방식을 선택적으
- `mode: 'hybrid'`: 키워드 검색 모달 + Ask AI 사이드 패널 활성화 (키워드 검색 구성 필요).
- `mode: 'modal'`: Ask AI를 DocSearch 모달 내부에 유지 (사이드 패널을 구성한 경우에도).
-### Ask AI만 (키워드 검색 없음) {#ask-ai-only}
+#### Ask AI만 (키워드 검색 없음) {#ask-ai-only}
**Ask AI 사이드 패널만** 사용하려면 최상위 키워드 검색 구성을 생략하고 `askAi` 아래에 자격 증명을 제공할 수 있습니다:
@@ -496,3 +329,9 @@ export default defineConfig({
}
})
```
+
+### 크롤러 구성 {#crawler-config}
+
+이 사이트에서 사용하는 예제 구성을 소개합니다:
+
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/pt/reference/default-theme-search.md b/docs/pt/reference/default-theme-search.md
index 3bbf3372..74e702e7 100644
--- a/docs/pt/reference/default-theme-search.md
+++ b/docs/pt/reference/default-theme-search.md
@@ -201,175 +201,14 @@ export default defineConfig({
Você pode usar uma configuração como esta para usar a pesquisa multilínguas:
-```ts
-import { defineConfig } from 'vitepress'
-
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: {
- buttonText: '搜索文档',
- buttonAriaLabel: '搜索文档'
- },
- modal: {
- searchBox: {
- resetButtonTitle: '清除查询条件',
- resetButtonAriaLabel: '清除查询条件',
- cancelButtonText: '取消',
- cancelButtonAriaLabel: '取消'
- },
- startScreen: {
- recentSearchesTitle: '搜索历史',
- noRecentSearchesText: '没有搜索历史',
- saveRecentSearchButtonTitle: '保存至搜索历史',
- removeRecentSearchButtonTitle: '从搜索历史中移除',
- favoriteSearchesTitle: '收藏',
- removeFavoriteSearchButtonTitle: '从收藏中移除'
- },
- errorScreen: {
- titleText: '无法获取结果',
- helpText: '你可能需要检查你的网络连接'
- },
- footer: {
- selectText: '选择',
- navigateText: '切换',
- closeText: '关闭',
- searchByText: '搜索提供者'
- },
- noResultsScreen: {
- noResultsText: '无法找到相关结果',
- suggestedQueryText: '你可以尝试查询',
- reportMissingResultsText: '你认为该查询应该有结果?',
- reportMissingResultsLinkText: '点击反馈'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+
+Clique para expandir
-[Essas opções](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) podem ser sobrepostas. Consulte a documentação oficial Algolia para obter mais informações sobre elas.
+<<< @/snippets/algolia-i18n.ts
-### Configuração _Crawler_ {#crawler-config}
+
-Aqui está um exemplo de configuração baseado na qual este site usa:
-
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+Consulte a [documentação oficial da Algolia](https://docsearch.algolia.com/docs/api#translations) para saber mais. Para começar rapidamente, você também pode copiar as traduções usadas por este site do [nosso repositório no GitHub](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code).
### Suporte ao Algolia Ask AI {#ask-ai}
@@ -388,8 +227,6 @@ options: {
Caso queira apenas a pesquisa por palavra-chave, omita `askAi`.
:::
-As traduções para Ask AI dentro do **modal** estão em `options.translations.modal.askAiScreen` e `options.translations.modal.resultsScreen` — consulte as [definições de tipos](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) para todas as chaves.
-
### Painel Lateral do Ask AI {#ask-ai-side-panel}
O DocSearch v4.5+ suporta um **painel lateral do Ask AI** opcional. Quando habilitado, pode ser aberto com **Ctrl/Cmd+I** por padrão. A [Referência da API do Painel Lateral](https://docsearch.algolia.com/docs/sidepanel/api-reference) contém a lista completa de opções.
@@ -451,11 +288,7 @@ export default defineConfig({
})
```
-#### i18n do painel lateral
-
-As traduções do painel lateral são configuradas em `options.askAi.sidePanel.panel.translations`. Consulte as [definições de tipos](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) para a estrutura completa.
-
-### Modo (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### Modo (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
Você pode controlar opcionalmente como o VitePress integra a pesquisa por palavra-chave e o Ask AI:
@@ -464,7 +297,7 @@ Você pode controlar opcionalmente como o VitePress integra a pesquisa por palav
- `mode: 'hybrid'`: habilita o modal de pesquisa por palavra-chave + painel lateral do Ask AI (requer configuração de pesquisa por palavra-chave).
- `mode: 'modal'`: mantém o Ask AI dentro do modal do DocSearch (mesmo se você configurou o painel lateral).
-### Apenas Ask AI (sem pesquisa por palavra-chave) {#ask-ai-only}
+#### Apenas Ask AI (sem pesquisa por palavra-chave) {#ask-ai-only}
Se quiser usar **apenas o painel lateral do Ask AI**, você pode omitir a configuração de pesquisa por palavra-chave de nível superior e fornecer as credenciais em `askAi`:
@@ -489,3 +322,9 @@ export default defineConfig({
}
})
```
+
+### Configuração _Crawler_ {#crawler-config}
+
+Aqui está um exemplo de configuração baseado na qual este site usa:
+
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/ru/reference/default-theme-search.md b/docs/ru/reference/default-theme-search.md
index f5d95a6d..c91d3e92 100644
--- a/docs/ru/reference/default-theme-search.md
+++ b/docs/ru/reference/default-theme-search.md
@@ -212,98 +212,14 @@ export default defineConfig({
Пример конфигурации для использования многоязычного поиска:
-```ts
-import { defineConfig } from 'vitepress'
+
+Нажмите, чтобы развернуть
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- ru: {
- placeholder: 'Поиск в документации',
- translations: {
- button: {
- buttonText: 'Поиск',
- buttonAriaLabel: 'Поиск'
- },
- modal: {
- searchBox: {
- clearButtonTitle: 'Очистить поиск',
- clearButtonAriaLabel: 'Очистить поиск',
- closeButtonText: 'Закрыть',
- closeButtonAriaLabel: 'Закрыть',
- placeholderText: 'Поиск в документации',
- placeholderTextAskAi: 'Задайте вопрос ИИ:',
- placeholderTextAskAiStreaming: 'Формируется ответ...',
- searchInputLabel: 'Поиск',
- backToKeywordSearchButtonText: 'Вернуться к поиску по ключевым словам',
- backToKeywordSearchButtonAriaLabel: 'Вернуться к поиску по ключевым словам'
- },
- startScreen: {
- recentSearchesTitle: 'История поиска',
- noRecentSearchesText: 'Нет истории поиска',
- saveRecentSearchButtonTitle: 'Сохранить в истории поиска',
- removeRecentSearchButtonTitle: 'Удалить из истории поиска',
- favoriteSearchesTitle: 'Избранное',
- removeFavoriteSearchButtonTitle: 'Удалить из избранного',
- recentConversationsTitle: 'Последние диалоги',
- removeRecentConversationButtonTitle: 'Удалить диалог из истории'
- },
- errorScreen: {
- titleText: 'Невозможно получить результаты',
- helpText: 'Проверьте подключение к Интернету'
- },
- noResultsScreen: {
- noResultsText: 'Ничего не найдено',
- suggestedQueryText: 'Попробуйте изменить запрос',
- reportMissingResultsText: 'Считаете, что результаты должны быть?',
- reportMissingResultsLinkText: 'Сообщите об этом'
- },
- resultsScreen: {
- askAiPlaceholder: 'Задайте вопрос ИИ: '
- },
- askAiScreen: {
- disclaimerText: 'Ответ сгенерирован ИИ и может быть неточным. Пожалуйста, проверьте информацию самостоятельно.',
- relatedSourcesText: 'Связанные источники',
- thinkingText: 'Думаю...',
- copyButtonText: 'Копировать',
- copyButtonCopiedText: 'Скопировано!',
- copyButtonTitle: 'Копировать',
- likeButtonTitle: 'Нравится',
- dislikeButtonTitle: 'Не нравится',
- thanksForFeedbackText: 'Спасибо за ваш отзыв!',
- preToolCallText: 'Идёт поиск...',
- duringToolCallText: 'Поиск ',
- afterToolCallText: 'Поиск выполнен'
- },
- footer: {
- selectText: 'выбрать',
- submitQuestionText: 'Отправить вопрос',
- selectKeyAriaLabel: 'Клавиша Enter',
- navigateText: 'перейти',
- navigateUpKeyAriaLabel: 'Стрелка вверх',
- navigateDownKeyAriaLabel: 'Стрелка вниз',
- closeText: 'закрыть',
- backToSearchText: 'Вернуться к поиску',
- closeKeyAriaLabel: 'Клавиша Esc',
- poweredByText: 'поиск от'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
+
+
-[Эти параметры](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts) можно переопределить. Чтобы узнать о них больше, обратитесь к официальной документации Algolia.
+Подробности см. в [официальной документации Algolia](https://docsearch.algolia.com/docs/api#translations). Чтобы быстрее начать, можно также скопировать переводы, используемые на этом сайте, из [нашего репозитория GitHub](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code).
### Поддержка Ask AI в Algolia {#ask-ai}
@@ -340,8 +256,6 @@ export default defineConfig({
Если вы хотите использовать обычный поиск по ключевым словам без Ask AI, просто не указывайте свойство `askAi`
:::
-Переводы для Ask AI внутри **модального окна** находятся в `options.translations.modal.askAiScreen` и `options.translations.modal.resultsScreen` — полный список ключей смотрите в [типах](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts).
-
### Боковая панель Ask AI {#ask-ai-side-panel}
DocSearch v4.5+ поддерживает опциональную **боковую панель Ask AI**. Когда она включена, её можно открыть с помощью **Ctrl/Cmd+I** по умолчанию. [Справочник API боковой панели](https://docsearch.algolia.com/docs/sidepanel/api-reference) содержит полный список опций.
@@ -403,11 +317,7 @@ export default defineConfig({
})
```
-#### i18n боковой панели
-
-Переводы боковой панели настраиваются в `options.askAi.sidePanel.panel.translations`. Полную структуру смотрите в [типах](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts).
-
-### Режим (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### Режим (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
Вы можете опционально контролировать, как VitePress интегрирует поиск по ключевым словам и Ask AI:
@@ -416,7 +326,7 @@ export default defineConfig({
- `mode: 'hybrid'`: включает модальное окно поиска по ключевым словам + боковую панель Ask AI (требует настройки поиска по ключевым словам).
- `mode: 'modal'`: сохраняет Ask AI внутри модального окна DocSearch (даже если вы настроили боковую панель).
-### Только Ask AI (без поиска по ключевым словам) {#ask-ai-only}
+#### Только Ask AI (без поиска по ключевым словам) {#ask-ai-only}
Если вы хотите использовать **только боковую панель Ask AI**, вы можете опустить конфигурацию поиска по ключевым словам верхнего уровня и предоставить учётные данные в `askAi`:
@@ -446,106 +356,4 @@ export default defineConfig({
Вот пример конфигурации, основанной на той, что используется на этом сайте:
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
\ No newline at end of file
+<<< @/snippets/algolia-crawler.js
diff --git a/docs/snippets/algolia-crawler.js b/docs/snippets/algolia-crawler.js
new file mode 100644
index 00000000..054afa56
--- /dev/null
+++ b/docs/snippets/algolia-crawler.js
@@ -0,0 +1,101 @@
+new Crawler({
+ appId: '...',
+ apiKey: '...',
+ rateLimit: 8,
+ startUrls: ['https://vitepress.dev/'],
+ renderJavaScript: false,
+ sitemaps: [],
+ exclusionPatterns: [],
+ ignoreCanonicalTo: false,
+ discoveryPatterns: ['https://vitepress.dev/**'],
+ schedule: 'at 05:10 on Saturday',
+ actions: [
+ {
+ indexName: 'vitepress',
+ pathsToMatch: ['https://vitepress.dev/**'],
+ recordExtractor: ({ $, helpers }) => {
+ return helpers.docsearch({
+ recordProps: {
+ lvl1: '.content h1',
+ content: '.content p, .content li',
+ lvl0: {
+ selectors: 'section.has-active div h2',
+ defaultValue: 'Documentation'
+ },
+ lvl2: '.content h2',
+ lvl3: '.content h3',
+ lvl4: '.content h4',
+ lvl5: '.content h5'
+ },
+ indexHeadings: true
+ })
+ }
+ }
+ ],
+ initialIndexSettings: {
+ vitepress: {
+ attributesForFaceting: ['type', 'lang'],
+ attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
+ attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
+ attributesToSnippet: ['content:10'],
+ camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
+ searchableAttributes: [
+ 'unordered(hierarchy_radio_camel.lvl0)',
+ 'unordered(hierarchy_radio.lvl0)',
+ 'unordered(hierarchy_radio_camel.lvl1)',
+ 'unordered(hierarchy_radio.lvl1)',
+ 'unordered(hierarchy_radio_camel.lvl2)',
+ 'unordered(hierarchy_radio.lvl2)',
+ 'unordered(hierarchy_radio_camel.lvl3)',
+ 'unordered(hierarchy_radio.lvl3)',
+ 'unordered(hierarchy_radio_camel.lvl4)',
+ 'unordered(hierarchy_radio.lvl4)',
+ 'unordered(hierarchy_radio_camel.lvl5)',
+ 'unordered(hierarchy_radio.lvl5)',
+ 'unordered(hierarchy_radio_camel.lvl6)',
+ 'unordered(hierarchy_radio.lvl6)',
+ 'unordered(hierarchy_camel.lvl0)',
+ 'unordered(hierarchy.lvl0)',
+ 'unordered(hierarchy_camel.lvl1)',
+ 'unordered(hierarchy.lvl1)',
+ 'unordered(hierarchy_camel.lvl2)',
+ 'unordered(hierarchy.lvl2)',
+ 'unordered(hierarchy_camel.lvl3)',
+ 'unordered(hierarchy.lvl3)',
+ 'unordered(hierarchy_camel.lvl4)',
+ 'unordered(hierarchy.lvl4)',
+ 'unordered(hierarchy_camel.lvl5)',
+ 'unordered(hierarchy.lvl5)',
+ 'unordered(hierarchy_camel.lvl6)',
+ 'unordered(hierarchy.lvl6)',
+ 'content'
+ ],
+ distinct: true,
+ attributeForDistinct: 'url',
+ customRanking: [
+ 'desc(weight.pageRank)',
+ 'desc(weight.level)',
+ 'asc(weight.position)'
+ ],
+ ranking: [
+ 'words',
+ 'filters',
+ 'typo',
+ 'attribute',
+ 'proximity',
+ 'exact',
+ 'custom'
+ ],
+ highlightPreTag: '',
+ highlightPostTag: '',
+ minWordSizefor1Typo: 3,
+ minWordSizefor2Typos: 7,
+ allowTyposOnNumericTokens: false,
+ minProximity: 1,
+ ignorePlurals: true,
+ advancedSyntax: true,
+ attributeCriteriaComputedByMinProximity: true,
+ removeWordsIfNoResults: 'allOptional'
+ }
+ }
+})
diff --git a/docs/snippets/algolia-i18n.ts b/docs/snippets/algolia-i18n.ts
new file mode 100644
index 00000000..c57816c3
--- /dev/null
+++ b/docs/snippets/algolia-i18n.ts
@@ -0,0 +1,155 @@
+import { defineConfig } from 'vitepress'
+
+export default defineConfig({
+ themeConfig: {
+ search: {
+ provider: 'algolia',
+ options: {
+ appId: '...',
+ apiKey: '...',
+ indexName: '...',
+ locales: {
+ zh: {
+ translations: {
+ button: {
+ buttonText: '搜索',
+ buttonAriaLabel: '搜索'
+ },
+ modal: {
+ searchBox: {
+ clearButtonTitle: '清除',
+ clearButtonAriaLabel: '清除查询',
+ closeButtonText: '关闭',
+ closeButtonAriaLabel: '关闭',
+ placeholderText: '搜索文档或向 AI 提问',
+ placeholderTextAskAi: '再问一个问题...',
+ placeholderTextAskAiStreaming: '正在回答...',
+ searchInputLabel: '搜索',
+ backToKeywordSearchButtonText: '返回关键词搜索',
+ backToKeywordSearchButtonAriaLabel: '返回关键词搜索',
+ newConversationPlaceholder: '提问',
+ conversationHistoryTitle: '我的对话历史',
+ startNewConversationText: '开始新的对话',
+ viewConversationHistoryText: '对话历史',
+ threadDepthErrorPlaceholder: '对话已达上限'
+ },
+ newConversation: {
+ newConversationTitle: '我今天能帮你什么?',
+ newConversationDescription:
+ '我会搜索你的文档,快速帮你找到设置指南、功能细节和故障排除提示。'
+ },
+ footer: {
+ selectText: '选择',
+ submitQuestionText: '提交问题',
+ selectKeyAriaLabel: '回车键',
+ navigateText: '导航',
+ navigateUpKeyAriaLabel: '向上箭头',
+ navigateDownKeyAriaLabel: '向下箭头',
+ closeText: '关闭',
+ backToSearchText: '返回搜索',
+ closeKeyAriaLabel: 'Esc 键',
+ poweredByText: '由…提供支持'
+ },
+ errorScreen: {
+ titleText: '无法获取结果',
+ helpText: '你可能需要检查网络连接。'
+ },
+ startScreen: {
+ recentSearchesTitle: '最近',
+ noRecentSearchesText: '暂无最近搜索',
+ saveRecentSearchButtonTitle: '保存此搜索',
+ removeRecentSearchButtonTitle: '从历史记录中移除此搜索',
+ favoriteSearchesTitle: '收藏',
+ removeFavoriteSearchButtonTitle: '从收藏中移除此搜索',
+ recentConversationsTitle: '最近对话',
+ removeRecentConversationButtonTitle: '从历史记录中移除此对话'
+ },
+ noResultsScreen: {
+ noResultsText: '未找到相关结果',
+ suggestedQueryText: '尝试搜索',
+ reportMissingResultsText: '认为此查询应该有结果?',
+ reportMissingResultsLinkText: '告诉我们。'
+ },
+ resultsScreen: {
+ askAiPlaceholder: '询问 AI:',
+ noResultsAskAiPlaceholder: '文档里没找到?让 Ask AI 帮忙:'
+ },
+ askAiScreen: {
+ disclaimerText: '回答由 AI 生成,可能会出错。请核实。',
+ relatedSourcesText: '相关来源',
+ thinkingText: '思考中...',
+ copyButtonText: '复制',
+ copyButtonCopiedText: '已复制!',
+ copyButtonTitle: '复制',
+ likeButtonTitle: '喜欢',
+ dislikeButtonTitle: '不喜欢',
+ thanksForFeedbackText: '感谢你的反馈!',
+ preToolCallText: '搜索中...',
+ duringToolCallText: '搜索中...',
+ afterToolCallText: '已搜索',
+ stoppedStreamingText: '你已停止此回复',
+ errorTitleText: '聊天错误',
+ threadDepthExceededMessage: '为保持回答准确,此对话已关闭。',
+ startNewConversationButtonText: '开始新的对话'
+ }
+ }
+ },
+ askAi: {
+ sidePanel: {
+ button: {
+ translations: {
+ buttonText: '询问 AI',
+ buttonAriaLabel: '询问 AI'
+ }
+ },
+ panel: {
+ translations: {
+ header: {
+ title: '询问 AI',
+ conversationHistoryTitle: '我的对话历史',
+ newConversationText: '开始新的对话',
+ viewConversationHistoryText: '对话历史'
+ },
+ promptForm: {
+ promptPlaceholderText: '提问',
+ promptAnsweringText: '正在回答...',
+ promptAskAnotherQuestionText: '再问一个问题',
+ promptDisclaimerText: '回答由 AI 生成,可能会出错。',
+ promptLabelText: '按回车发送,Shift+回车换行。',
+ promptAriaLabelText: '问题输入'
+ },
+ conversationScreen: {
+ preToolCallText: '搜索中...',
+ searchingText: '搜索中...',
+ toolCallResultText: '已搜索',
+ conversationDisclaimer:
+ '回答由 AI 生成,可能会出错。请核实。',
+ reasoningText: '推理中...',
+ thinkingText: '思考中...',
+ relatedSourcesText: '相关来源',
+ stoppedStreamingText: '你已停止此回复',
+ copyButtonText: '复制',
+ copyButtonCopiedText: '已复制!',
+ likeButtonTitle: '喜欢',
+ dislikeButtonTitle: '不喜欢',
+ thanksForFeedbackText: '感谢你的反馈!',
+ errorTitleText: '聊天错误'
+ },
+ newConversationScreen: {
+ titleText: '我今天能帮你什么?',
+ introductionText:
+ '我会搜索你的文档,快速帮你找到设置指南、功能细节和故障排除提示。'
+ },
+ logo: {
+ poweredByText: '由…提供支持'
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+})
diff --git a/docs/zh/reference/default-theme-search.md b/docs/zh/reference/default-theme-search.md
index 6b37bc89..13bc1e37 100644
--- a/docs/zh/reference/default-theme-search.md
+++ b/docs/zh/reference/default-theme-search.md
@@ -201,91 +201,14 @@ export default defineConfig({
你可以使用这样的配置来使用多语言搜索:
-```ts
-import { defineConfig } from 'vitepress'
+
+点击展开
-export default defineConfig({
- themeConfig: {
- search: {
- provider: 'algolia',
- options: {
- appId: '...',
- apiKey: '...',
- indexName: '...',
- locales: {
- zh: {
- placeholder: '搜索文档',
- translations: {
- button: { buttonText: '搜索文档', buttonAriaLabel: '搜索文档' },
- modal: {
- searchBox: {
- clearButtonTitle: '清除查询条件',
- clearButtonAriaLabel: '清除查询条件',
- closeButtonText: '关闭',
- closeButtonAriaLabel: '关闭',
- placeholderText: '搜索文档',
- placeholderTextAskAi: '向 AI 提问:',
- placeholderTextAskAiStreaming: '回答中...',
- searchInputLabel: '搜索',
- backToKeywordSearchButtonText: '返回关键字搜索',
- backToKeywordSearchButtonAriaLabel: '返回关键字搜索'
- },
- startScreen: {
- recentSearchesTitle: '搜索历史',
- noRecentSearchesText: '没有搜索历史',
- saveRecentSearchButtonTitle: '保存至搜索历史',
- removeRecentSearchButtonTitle: '从搜索历史中移除',
- favoriteSearchesTitle: '收藏',
- removeFavoriteSearchButtonTitle: '从收藏中移除',
- recentConversationsTitle: '最近的对话',
- removeRecentConversationButtonTitle: '从历史记录中删除对话'
- },
- errorScreen: {
- titleText: '无法获取结果',
- helpText: '请检查网络连接'
- },
- noResultsScreen: {
- noResultsText: '无法找到相关结果',
- suggestedQueryText: '你可以尝试查询',
- reportMissingResultsText: '你认为该查询应该有结果?',
- reportMissingResultsLinkText: '点击反馈'
- },
- resultsScreen: { askAiPlaceholder: '向 AI 提问: ' },
- askAiScreen: {
- disclaimerText: '答案由 AI 生成,可能不准确,请自行验证。',
- relatedSourcesText: '相关来源',
- thinkingText: '思考中...',
- copyButtonText: '复制',
- copyButtonCopiedText: '已复制!',
- copyButtonTitle: '复制',
- likeButtonTitle: '赞',
- dislikeButtonTitle: '踩',
- thanksForFeedbackText: '感谢你的反馈!',
- preToolCallText: '搜索中...',
- duringToolCallText: '搜索 ',
- afterToolCallText: '已搜索'
- },
- footer: {
- selectText: '选择',
- submitQuestionText: '提交问题',
- selectKeyAriaLabel: 'Enter 键',
- navigateText: '切换',
- navigateUpKeyAriaLabel: '向上箭头',
- navigateDownKeyAriaLabel: '向下箭头',
- closeText: '关闭',
- backToSearchText: '返回搜索',
- closeKeyAriaLabel: 'Esc 键',
- poweredByText: '搜索提供者'
- }
- }
- }
- }
- }
- }
- }
- }
-})
-```
+<<< @/snippets/algolia-i18n.ts
+
+
+
+更多信息请参考[官方 Algolia 文档](https://docsearch.algolia.com/docs/api#translations)。想要快速开始,你也可以从[我们的 GitHub 仓库](https://github.com/search?q=repo:vuejs/vitepress+%22function+searchOptions%22&type=code)复制此站点使用的翻译。
### Algolia Ask AI 支持 {#ask-ai}
@@ -306,8 +229,6 @@ options: {
若仅需关键词搜索,可省略 `askAi`。
:::
-**模态框**中 Ask AI 的翻译位于 `options.translations.modal.askAiScreen` 和 `options.translations.modal.resultsScreen` — 查看[类型定义](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)了解所有键。
-
### Ask AI 侧边栏 {#ask-ai-side-panel}
DocSearch v4.5+ 支持可选的 **Ask AI 侧边栏**。启用后,默认可通过 **Ctrl/Cmd+I** 打开。完整的选项列表请参阅[侧边栏 API 参考](https://docsearch.algolia.com/docs/sidepanel/api-reference)。
@@ -369,11 +290,7 @@ export default defineConfig({
})
```
-#### 侧边栏 i18n
-
-侧边栏翻译配置在 `options.askAi.sidePanel.panel.translations` 下。完整的结构请参考[类型定义](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts)。
-
-### 模式 (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
+#### 模式 (auto / sidePanel / hybrid / modal) {#ask-ai-mode}
你可以选择性地控制 VitePress 如何集成关键词搜索和 Ask AI:
@@ -382,7 +299,7 @@ export default defineConfig({
- `mode: 'hybrid'`:启用关键词搜索模态框 + Ask AI 侧边栏(需要关键词搜索配置)。
- `mode: 'modal'`:将 Ask AI 保留在 DocSearch 模态框内(即使你配置了侧边栏)。
-### 仅 Ask AI(无关键词搜索) {#ask-ai-only}
+#### 仅 Ask AI(无关键词搜索) {#ask-ai-only}
如果你想**仅使用 Ask AI 侧边栏**,可以省略顶级关键词搜索配置,并在 `askAi` 下提供凭据:
@@ -412,106 +329,4 @@ export default defineConfig({
以下是基于此站点使用的示例配置:
-```ts
-new Crawler({
- appId: '...',
- apiKey: '...',
- rateLimit: 8,
- startUrls: ['https://vitepress.dev/'],
- renderJavaScript: false,
- sitemaps: [],
- exclusionPatterns: [],
- ignoreCanonicalTo: false,
- discoveryPatterns: ['https://vitepress.dev/**'],
- schedule: 'at 05:10 on Saturday',
- actions: [
- {
- indexName: 'vitepress',
- pathsToMatch: ['https://vitepress.dev/**'],
- recordExtractor: ({ $, helpers }) => {
- return helpers.docsearch({
- recordProps: {
- lvl1: '.content h1',
- content: '.content p, .content li',
- lvl0: {
- selectors: 'section.has-active div h2',
- defaultValue: 'Documentation'
- },
- lvl2: '.content h2',
- lvl3: '.content h3',
- lvl4: '.content h4',
- lvl5: '.content h5'
- },
- indexHeadings: true
- })
- }
- }
- ],
- initialIndexSettings: {
- vitepress: {
- attributesForFaceting: ['type', 'lang'],
- attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url'],
- attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],
- attributesToSnippet: ['content:10'],
- camelCaseAttributes: ['hierarchy', 'hierarchy_radio', 'content'],
- searchableAttributes: [
- 'unordered(hierarchy_radio_camel.lvl0)',
- 'unordered(hierarchy_radio.lvl0)',
- 'unordered(hierarchy_radio_camel.lvl1)',
- 'unordered(hierarchy_radio.lvl1)',
- 'unordered(hierarchy_radio_camel.lvl2)',
- 'unordered(hierarchy_radio.lvl2)',
- 'unordered(hierarchy_radio_camel.lvl3)',
- 'unordered(hierarchy_radio.lvl3)',
- 'unordered(hierarchy_radio_camel.lvl4)',
- 'unordered(hierarchy_radio.lvl4)',
- 'unordered(hierarchy_radio_camel.lvl5)',
- 'unordered(hierarchy_radio.lvl5)',
- 'unordered(hierarchy_radio_camel.lvl6)',
- 'unordered(hierarchy_radio.lvl6)',
- 'unordered(hierarchy_camel.lvl0)',
- 'unordered(hierarchy.lvl0)',
- 'unordered(hierarchy_camel.lvl1)',
- 'unordered(hierarchy.lvl1)',
- 'unordered(hierarchy_camel.lvl2)',
- 'unordered(hierarchy.lvl2)',
- 'unordered(hierarchy_camel.lvl3)',
- 'unordered(hierarchy.lvl3)',
- 'unordered(hierarchy_camel.lvl4)',
- 'unordered(hierarchy.lvl4)',
- 'unordered(hierarchy_camel.lvl5)',
- 'unordered(hierarchy.lvl5)',
- 'unordered(hierarchy_camel.lvl6)',
- 'unordered(hierarchy.lvl6)',
- 'content'
- ],
- distinct: true,
- attributeForDistinct: 'url',
- customRanking: [
- 'desc(weight.pageRank)',
- 'desc(weight.level)',
- 'asc(weight.position)'
- ],
- ranking: [
- 'words',
- 'filters',
- 'typo',
- 'attribute',
- 'proximity',
- 'exact',
- 'custom'
- ],
- highlightPreTag: '',
- highlightPostTag: '',
- minWordSizefor1Typo: 3,
- minWordSizefor2Typos: 7,
- allowTyposOnNumericTokens: false,
- minProximity: 1,
- ignorePlurals: true,
- advancedSyntax: true,
- attributeCriteriaComputedByMinProximity: true,
- removeWordsIfNoResults: 'allOptional'
- }
- }
-})
-```
+<<< @/snippets/algolia-crawler.js