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 { defineConfig } from 'vitepress'
import nav from './nav' import nav from './nav'
import mdPangu from "markdown-it-pangu" import mdPangu from 'markdown-it-pangu'
import katex from 'markdown-it-katex' import katex from 'markdown-it-katex'
import footnote from 'markdown-it-footnote' import footnote from 'markdown-it-footnote'
import { sidebar } from './sidebar' import { sidebar } from './sidebar'
@ -9,8 +9,8 @@ import { rootDir, githubRepoLink } from './meta'
// https://vitepress.dev/reference/site-config // https://vitepress.dev/reference/site-config
export default defineConfig({ export default defineConfig({
lang: 'zh-CN', lang: 'zh-CN',
title: "RLE.wiki", title: 'RLE.wiki',
description: "一份 RLE 指北", description: '一份 RLE 指北',
markdown: { markdown: {
config(md) { config(md) {
md.use(mdPangu); md.use(mdPangu);
@ -24,16 +24,13 @@ export default defineConfig({
siteTitle: 'RLE.wiki', siteTitle: 'RLE.wiki',
nav, nav,
sidebar, sidebar,
socialLinks: [ socialLinks: [
{ icon: 'github', link: githubRepoLink } { icon: 'github', link: githubRepoLink }
], ],
editLink: { editLink: {
pattern: `${githubRepoLink}/edit/main/docs/:path`, pattern: `${githubRepoLink}/edit/main/docs/:path`,
text: '在 GitHub 上编辑此页面', // label localization text: '在 GitHub 上编辑此页面', // label localization
}, },
// label localization // label localization
outline: { label: '本页大纲', level: 'deep' }, outline: { label: '本页大纲', level: 'deep' },
lastUpdated: { text: '最后更新' }, lastUpdated: { text: '最后更新' },
@ -44,5 +41,28 @@ export default defineConfig({
prev: '上一页', prev: '上一页',
next: '下一页', 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 = [ const nav: NavConfig = [
{ {
text: "大学指南", text: '大学指南',
link: "/campus/", link: '/campus/',
}, },
{ {
text: "Fashion", text: 'Fashion',
link: "/fashion/", link: '/fashion/',
}, },
{ {
text: "贡献指南", text: '贡献指南',
items: [{ items: [
text: "校园版块投稿指南", {
link: "/contributor-guide/campus.md", text: '校园版块投稿指南',
}, { link: '/contributor-guide/campus.md',
text: "其他投稿指南", },
link: "/contributor-guide/other.md", {
}, { text: '其他投稿指南',
text: "校园版块贡献模板", link: '/contributor-guide/other.md',
link: "/contributor-guide/CampusTemplate.md", },
}], {
text: '校园版块贡献模板',
link: '/contributor-guide/CampusTemplate.md',
},
],
}, },
]; ];