🔥 新增搜索功能

This commit is contained in:
远野千束 2024-08-31 07:54:41 +08:00
parent 25a6062837
commit 8eca5e2c22
4 changed files with 77 additions and 4 deletions

View File

@ -1,3 +1,5 @@
// 共有配置项导入index用
import {defineConfig} from 'vitepress'
import {generateSidebar} from 'vitepress-sidebar';
import {zh} from "./zh";
@ -71,11 +73,82 @@ export const common = defineConfig({
socialLinks: [
{icon: 'github', link: 'https://github.com/snowykami/mbcp'}
],
outline: [2, 6]
search: {
provider: 'local',
options: {
locales: {
root: {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '打开搜索框',
},
modal: {
noResultsText: '没有找到搜索结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
}
}
},
},
en: {
translations: {
button: {
buttonText: 'Search',
buttonAriaLabel: 'Search',
},
modal: {
noResultsText: 'No results found',
resetButtonTitle: 'Reset search query',
footer: {
selectText: 'Select',
navigateText: 'Navigate',
}
}
}
},
zht: {
translations: {
button: {
buttonText: '搜索文檔',
buttonAriaLabel: '打開搜索框',
},
modal: {
noResultsText: '沒有找到搜索結果',
resetButtonTitle: '清除查詢條件',
footer: {
selectText: '選擇',
navigateText: '切換',
}
}
}
},
ja: {
translations: {
button: {
buttonText: '検索',
buttonAriaLabel: '検索を開く',
},
modal: {
noResultsText: '検索結果が見つかりません',
resetButtonTitle: 'リセット',
footer: {
selectText: '選択',
navigateText: '移動',
}
}
}
}
}
}
}
},
sitemap: {
hostname: 'https://mbcp.sfkm.me'
},
lastUpdated: true,
locales: {
root: {label: "简体中文", ...zh},
en: {label: "English", ...en},

View File

@ -23,6 +23,6 @@ export const en = defineConfig({
message: 'Documentation built with <a href="https://vitepress.dev/">VitePress</a> | API references generated by <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a>',
copyright: ThemeConfig.copyright
},
outline: ThemeConfig.getOutLine("Page Content")
outline: ThemeConfig.getOutLine("Page Content"),
},
})

View File

@ -23,6 +23,6 @@ export const ja = defineConfig({
message: '<a href="https://vitepress.dev/">VitePress</a> で構築されたドキュメント | <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> によって生成されたAPIリファレンス',
copyright: ThemeConfig.copyright
},
outline: ThemeConfig.getOutLine("ページの内容")
outline: ThemeConfig.getOutLine("ページの内容"),
},
})

View File

@ -23,6 +23,6 @@ export const zh = defineConfig({
message: '文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成',
copyright: ThemeConfig.copyright
},
outline: ThemeConfig.getOutLine("页面内容")
outline: ThemeConfig.getOutLine("页面内容"),
},
})