feat: enabled local search that natively supported by VitePress (#236)

Signed-off-by: Neko Ayaka <neko@ayaka.moe>
pull/286/head
Neko Ayaka 2023-12-21 23:43:18 +08:00 committed by Rizumu Ayaka
parent 0193624411
commit e3c3c677fe
2 changed files with 47 additions and 23 deletions

View File

@ -1,6 +1,6 @@
import { defineConfig } from 'vitepress'
import nav from './nav'
import mdPangu from "markdown-it-pangu"
import mdPangu from 'markdown-it-pangu'
import katex from 'markdown-it-katex'
import footnote from 'markdown-it-footnote'
import { sidebar } from './sidebar'
@ -9,8 +9,8 @@ import { rootDir, githubRepoLink } from './meta'
// https://vitepress.dev/reference/site-config
export default defineConfig({
lang: 'zh-CN',
title: "RLE.wiki",
description: "一份 RLE 指北",
title: 'RLE.wiki',
description: '一份 RLE 指北',
markdown: {
config(md) {
md.use(mdPangu);
@ -24,16 +24,13 @@ export default defineConfig({
siteTitle: 'RLE.wiki',
nav,
sidebar,
socialLinks: [
{ icon: 'github', link: githubRepoLink }
],
editLink: {
pattern: `${githubRepoLink}/edit/main/docs/:path`,
text: '在 GitHub 上编辑此页面', // label localization
},
// label localization
outline: { label: '本页大纲', level: 'deep' },
lastUpdated: { text: '最后更新' },
@ -44,5 +41,28 @@ export default defineConfig({
prev: '上一页',
next: '下一页',
},
}
})
search: {
provider: 'local',
options: {
locales: {
root: {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
},
},
},
},
},
},
},
},
});

View File

@ -4,25 +4,29 @@ type NavConfig = DefaultTheme.Config['nav']
const nav: NavConfig = [
{
text: "大学指南",
link: "/campus/",
text: '大学指南',
link: '/campus/',
},
{
text: "Fashion",
link: "/fashion/",
text: 'Fashion',
link: '/fashion/',
},
{
text: "贡献指南",
items: [{
text: "校园版块投稿指南",
link: "/contributor-guide/campus.md",
}, {
text: "其他投稿指南",
link: "/contributor-guide/other.md",
}, {
text: "校园版块贡献模板",
link: "/contributor-guide/CampusTemplate.md",
}],
text: '贡献指南',
items: [
{
text: '校园版块投稿指南',
link: '/contributor-guide/campus.md',
},
{
text: '其他投稿指南',
link: '/contributor-guide/other.md',
},
{
text: '校园版块贡献模板',
link: '/contributor-guide/CampusTemplate.md',
},
],
},
];