2
0
mirror of https://github.com/acepanel/acepanel.github.io.git synced 2026-02-04 04:22:29 +08:00

feat: 支持algolia搜索

This commit is contained in:
2026-01-26 00:17:23 +08:00
parent 8222160298
commit b02d287e67
3 changed files with 107 additions and 17 deletions

View File

@@ -1,58 +1,142 @@
import type {DefaultTheme} from "vitepress";
export const enSearch: DefaultTheme.LocalSearchOptions['locales'] = {
root: {
export const enSearch: DefaultTheme.AlgoliaSearchOptions['locales'] = {
en: {
placeholder: 'Search docs',
translations: {
button: {
buttonText: 'Search',
buttonAriaLabel: 'Search'
},
modal: {
noResultsText: 'No results for',
resetButtonTitle: 'Clear the search query',
searchBox: {
clearButtonTitle: 'Clear the query',
clearButtonAriaLabel: 'Clear the query',
closeButtonText: 'Cancel',
closeButtonAriaLabel: 'Cancel'
},
startScreen: {
recentSearchesTitle: 'Recent',
noRecentSearchesText: 'No recent searches',
saveRecentSearchButtonTitle: 'Save this search',
removeRecentSearchButtonTitle: 'Remove this search from history',
favoriteSearchesTitle: 'Favorite',
removeFavoriteSearchButtonTitle: 'Remove this search from favorites'
},
errorScreen: {
titleText: 'Unable to fetch results',
helpText: 'You might want to check your network connection'
},
footer: {
selectText: 'Select',
selectKeyAriaLabel: 'Enter key',
navigateText: 'Navigate',
navigateUpKeyAriaLabel: 'Arrow up',
navigateDownKeyAriaLabel: 'Arrow down',
closeText: 'Close',
closeKeyAriaLabel: 'Escape key'
},
noResultsScreen: {
noResultsText: 'No results for',
suggestedQueryText: 'Try searching for',
reportMissingResultsText: 'Believe this query should return results?',
reportMissingResultsLinkText: 'Let us know'
}
}
}
}
}
export const zh_CNSearch: DefaultTheme.LocalSearchOptions['locales'] = {
zh_CN: {
export const zh_CNSearch: DefaultTheme.AlgoliaSearchOptions['locales'] = {
root: {
placeholder: '搜索文档',
translations: {
button: {
buttonText: '搜索',
buttonAriaLabel: '搜索'
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档'
},
modal: {
noResultsText: '没有找到相关结果:',
resetButtonTitle: '清除搜索条件',
searchBox: {
clearButtonTitle: '清除查询条件',
clearButtonAriaLabel: '清除查询条件',
closeButtonText: '关闭',
closeButtonAriaLabel: '关闭'
},
startScreen: {
recentSearchesTitle: '搜索历史',
noRecentSearchesText: '没有搜索历史',
saveRecentSearchButtonTitle: '保存至搜索历史',
removeRecentSearchButtonTitle: '从搜索历史中移除',
favoriteSearchesTitle: '收藏',
removeFavoriteSearchButtonTitle: '从收藏中移除'
},
errorScreen: {
titleText: '无法获取结果',
helpText: '请检查网络连接'
},
footer: {
selectText: '选择',
selectKeyAriaLabel: 'Enter 键',
navigateText: '切换',
navigateUpKeyAriaLabel: '向上箭头',
navigateDownKeyAriaLabel: '向下箭头',
closeText: '关闭',
closeKeyAriaLabel: 'Esc 键'
},
noResultsScreen: {
noResultsText: '无法找到相关结果',
suggestedQueryText: '你可以尝试查询',
reportMissingResultsText: '你认为该查询应该有结果?',
reportMissingResultsLinkText: '点击反馈'
}
}
}
}
}
export const zh_TWSearch: DefaultTheme.LocalSearchOptions['locales'] = {
export const zh_TWSearch: DefaultTheme.AlgoliaSearchOptions['locales'] = {
zh_TW: {
placeholder: '搜尋文檔',
translations: {
button: {
buttonText: '搜尋',
buttonAriaLabel: '搜尋'
buttonText: '搜尋文檔',
buttonAriaLabel: '搜尋文檔'
},
modal: {
noResultsText: '沒有找到相關結果:',
resetButtonTitle: '清除搜尋條件',
searchBox: {
clearButtonTitle: '清除查詢條件',
clearButtonAriaLabel: '清除查詢條件',
closeButtonText: '關閉',
closeButtonAriaLabel: '關閉'
},
startScreen: {
recentSearchesTitle: '搜尋歷史',
noRecentSearchesText: '沒有搜尋歷史',
saveRecentSearchButtonTitle: '保存至搜尋歷史',
removeRecentSearchButtonTitle: '從搜尋歷史中移除',
favoriteSearchesTitle: '收藏',
removeFavoriteSearchButtonTitle: '從收藏中移除'
},
errorScreen: {
titleText: '無法獲取結果',
helpText: '請檢查網路連接'
},
footer: {
selectText: '選擇',
selectKeyAriaLabel: 'Enter 鍵',
navigateText: '切換',
navigateUpKeyAriaLabel: '向上箭頭',
navigateDownKeyAriaLabel: '向下箭頭',
closeText: '關閉',
closeKeyAriaLabel: 'Esc 鍵'
},
noResultsScreen: {
noResultsText: '無法找到相關結果',
suggestedQueryText: '你可以嘗試查詢',
reportMissingResultsText: '你認為該查詢應該有結果?',
reportMissingResultsLinkText: '點擊反饋'
}
}
}
}
}
}

View File

@@ -41,8 +41,11 @@ export const shared = defineConfig({
{icon: 'wechat', link: 'https://work.weixin.qq.com/gm/d8ebf618553398d454e3378695c858b6'},
],
search: {
provider: 'local',
provider: 'algolia',
options: {
appId: 'MQBORZ4OJ4',
apiKey: 'b453e45194dfbd6a7342728517d5b153',
indexName: 'acepanel',
locales: {
...enSearch,
...zh_CNSearch,

3
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,3 @@
onlyBuiltDependencies:
- esbuild
- less