Skip to content

Commit

Permalink
Update search options to use Algolia search in zh.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Leetfs committed Sep 8, 2024
1 parent 017c554 commit b4d85ed
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 54 deletions.
9 changes: 3 additions & 6 deletions docs/.vitepress/config/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineConfig } from 'vitepress'
import { search as zhSearch } from './zh'


export const shared = defineConfig({
title: 'study-wiki',

Expand Down Expand Up @@ -49,18 +48,16 @@ export const shared = defineConfig({
themeConfig: {
logo: { src: '/vitepress-logo-mini.svg', width: 24, height: 24 },

socialLinks: [
{ icon: 'github', link: 'https://github.com/Leetfs/study' }
],
socialLinks: [{ icon: 'github', link: 'https://github.com/Leetfs/study' }],

search: {
provider: 'algolia',
options: {
appId: '8J64VVRP8K',
apiKey: 'a18e2f4cc5665f6602c5631fd868adfd',
indexName: 'vitepress',
indexName: 'study-wiki',
locales: {
...zhSearch,
...zhSearch
}
}
},
Expand Down
92 changes: 44 additions & 48 deletions docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { createRequire } from 'module'
import { defineConfig, type DefaultTheme } from 'vitepress'

import { getSidebar } from '../../../src/node/utils/getSidebar'; // 根据项目结构调整路径

import { getSidebar } from '../../../src/node/utils/getSidebar' // 根据项目结构调整路径

const require = createRequire(import.meta.url)
const pkg = require('vitepress/package.json')
Expand Down Expand Up @@ -98,49 +97,46 @@ function nav(): DefaultTheme.NavItem[] {
]
}


// export const search: DefaultTheme.AlgoliaSearchOptions['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: '点击反馈'
// }
// }
// }
// }
// }


export const search: DefaultTheme.AlgoliaSearchOptions['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: '点击反馈'
}
}
}
}
}

0 comments on commit b4d85ed

Please sign in to comment.