From d5435c7d2951f56863135b659d1415bf2c843dc1 Mon Sep 17 00:00:00 2001 From: linkscope Date: Thu, 6 Mar 2025 20:14:38 +0800 Subject: [PATCH 1/4] docs: optimize search doc descriptions --- docs/zh/reference/default-theme-search.md | 54 ++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/docs/zh/reference/default-theme-search.md b/docs/zh/reference/default-theme-search.md index 31af2c9d..fa128a24 100644 --- a/docs/zh/reference/default-theme-search.md +++ b/docs/zh/reference/default-theme-search.md @@ -42,18 +42,62 @@ export default defineConfig({ zh: { translations: { button: { - buttonText: '搜索文档', - buttonAriaLabel: '搜索文档' + buttonText: '搜索', + buttonAriaLabel: '搜索' }, modal: { - noResultsText: '无法找到相关结果', - resetButtonTitle: '清除查询条件', + displayDetails: '显示详细列表', + resetButtonTitle: '重置搜索', + backButtonTitle: '关闭搜索', + noResultsText: '没有结果', footer: { selectText: '选择', - navigateText: '切换' + selectKeyAriaLabel: '输入', + navigateText: '导航', + navigateUpKeyAriaLabel: '上箭头', + navigateDownKeyAriaLabel: '下箭头', + closeText: '关闭', + closeKeyAriaLabel: 'esc' } } } + } + } + } + } + } +}) +``` + +如果你只想翻译默认语言,可以像这样配置: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + themeConfig: { + search: { + provider: 'local', + options: { + translations: { + button: { + buttonText: '搜索', + buttonAriaLabel: '搜索' + }, + modal: { + displayDetails: '显示详细列表', + resetButtonTitle: '重置搜索', + backButtonTitle: '关闭搜索', + noResultsText: '没有结果', + footer: { + selectText: '选择', + selectKeyAriaLabel: '输入', + navigateText: '导航', + navigateUpKeyAriaLabel: '上箭头', + navigateDownKeyAriaLabel: '下箭头', + closeText: '关闭', + closeKeyAriaLabel: 'esc' + } } } } From 92b5d764528f9da428391c14a344eb3bd10de202 Mon Sep 17 00:00:00 2001 From: linkscope Date: Thu, 6 Mar 2025 20:31:57 +0800 Subject: [PATCH 2/4] docs: add srcDir tip in asset doc --- docs/zh/guide/asset-handling.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/zh/guide/asset-handling.md b/docs/zh/guide/asset-handling.md index 69259a6a..6fc68817 100644 --- a/docs/zh/guide/asset-handling.md +++ b/docs/zh/guide/asset-handling.md @@ -20,6 +20,10 @@ 所有**静态**路径引用,包括绝对路径,都应基于你的工作目录的结构。 +::: tip 如果你使用了 `srcDir` +如果你使用了 [`srcDir`](../reference/site-config#srcdir) 配置项,[`public`](#the-public-directory) 目录应放置于 `srcDir` 目录下。 +::: + ## public 目录 {#the-public-directory} 有时可能需要一些静态资源,但这些资源没有直接被 Markdown 或主题组件直接引用,或者你可能想以原始文件名提供某些文件,像 `robots.txt`,favicons 和 PWA 图标这样的文件。 From b7e3286f928f61ec98d649860dfb07fb86577cb7 Mon Sep 17 00:00:00 2001 From: linkscope Date: Thu, 6 Mar 2025 20:32:10 +0800 Subject: [PATCH 3/4] docs: add English translate --- docs/en/guide/asset-handling.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/guide/asset-handling.md b/docs/en/guide/asset-handling.md index eeedc8c0..9a112fcd 100644 --- a/docs/en/guide/asset-handling.md +++ b/docs/en/guide/asset-handling.md @@ -20,6 +20,10 @@ All referenced assets, including those using absolute paths, will be copied to t All **static** path references, including absolute paths, should be based on your working directory structure. +::: tip If you use `srcDir` +If you use [`srcDir`](../reference/site-config#srcdir), [`public`](#the-public-directory) directory should be placed under the `srcDir` directory. +::: + ## The Public Directory Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components, or you may want to serve certain files with the original filename. Examples of such files include `robots.txt`, favicons, and PWA icons. From 429e5923325fab28361be2740f3728ee7ec66061 Mon Sep 17 00:00:00 2001 From: linkscope Date: Thu, 6 Mar 2025 20:42:02 +0800 Subject: [PATCH 4/4] docs: add English translate --- docs/en/reference/default-theme-search.md | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/en/reference/default-theme-search.md b/docs/en/reference/default-theme-search.md index d647e32e..05b7df12 100644 --- a/docs/en/reference/default-theme-search.md +++ b/docs/en/reference/default-theme-search.md @@ -43,7 +43,7 @@ export default defineConfig({ provider: 'local', options: { locales: { - zh: { // make this `root` if you want to translate the default locale + zh: { translations: { button: { buttonText: '搜索', @@ -73,6 +73,43 @@ export default defineConfig({ }) ``` +If you only want to translate the default language, you can configure it like this: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + themeConfig: { + search: { + provider: 'local', + options: { + translations: { + button: { + buttonText: '搜索', + buttonAriaLabel: '搜索' + }, + modal: { + displayDetails: '显示详细列表', + resetButtonTitle: '重置搜索', + backButtonTitle: '关闭搜索', + noResultsText: '没有结果', + footer: { + selectText: '选择', + selectKeyAriaLabel: '输入', + navigateText: '导航', + navigateUpKeyAriaLabel: '上箭头', + navigateDownKeyAriaLabel: '下箭头', + closeText: '关闭', + closeKeyAriaLabel: 'esc' + } + } + } + } + } + } +}) +``` + ### miniSearch options You can configure MiniSearch like this: