升级:vitepress 1.0.0-alpha.64 => 1.0.0-alpha.66(官方本地搜索已上线)

This commit is contained in:
2023-04-16 00:42:55 +08:00
parent 9d6cf29a46
commit 9bbe96d1a6
7 changed files with 202 additions and 106 deletions

View File

@@ -0,0 +1,50 @@
import type { AlgoliaSearchOptions } from 'vitepress';
export const algoliaSearchOptions: AlgoliaSearchOptions = {
appId: 'DBZ0G9HBUY',
apiKey: '00cef480a543003d05d9808110ea5f65',
indexName: 'charles7c',
locales: {
root: {
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: '点击反馈'
}
}
}
}
}
};

View File

@@ -0,0 +1,22 @@
import type { LocalSearchOptions } from 'vitepress';
export const localSearchOptions: LocalSearchOptions = {
locales: {
root: {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档'
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换'
}
}
}
}
}
};

View File

@@ -1,6 +1,8 @@
import type { DefaultTheme } from 'vitepress';
import { nav } from './nav';
import { sidebar } from './sidebar';
import { algoliaSearchOptions } from './search/algolia-search';
import { localSearchOptions } from './search/local-search';
export const themeConfig: DefaultTheme.Config = {
nav, // 导航栏配置
@@ -25,11 +27,13 @@ export const themeConfig: DefaultTheme.Config = {
pattern: 'https://github.com/Charles7c/charles7c.github.io/edit/main/docs/:path',
text: '不妥之处,敬请雅正'
},
// 全文搜索配置
algolia: {
appId: 'DBZ0G9HBUY',
apiKey: '00cef480a543003d05d9808110ea5f65',
indexName: 'charles7c'
// 搜索配置(二选一)
search: {
provider: 'algolia',
options: algoliaSearchOptions,
// 本地离线搜索
// provider: 'local',
// options: localSearchOptions
},
// 导航栏右侧社交链接配置
socialLinks: [

View File

@@ -1,16 +1,9 @@
import { defineConfig } from 'vite';
import Components from 'unplugin-vue-components/vite';
import { ArcoResolver } from 'unplugin-vue-components/resolvers';
// import { pagefindPlugin } from 'vitepress-plugin-pagefind';
export default defineConfig({
plugins: [
// pagefindPlugin({
// btnPlaceholder: '搜索',
// placeholder: '搜索文档',
// emptyText: '空空如也',
// heading: '共 {{searchResult}} 条结果'
// }),
Components({
dirs: ['.vitepress/theme/components'],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],