From e3c3c677fe5c650f17f6b5f5ff1b17c59565c2e6 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Thu, 21 Dec 2023 23:43:18 +0800 Subject: [PATCH] feat: enabled local search that natively supported by VitePress (#236) Signed-off-by: Neko Ayaka --- docs/.vitepress/config.ts | 36 ++++++++++++++++++++++++++++-------- docs/.vitepress/nav.ts | 34 +++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 40e9cc5..75c1199 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -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: '切换', + }, + }, + }, + }, + }, + }, + }, + }, +}); diff --git a/docs/.vitepress/nav.ts b/docs/.vitepress/nav.ts index 34007ba..157205b 100644 --- a/docs/.vitepress/nav.ts +++ b/docs/.vitepress/nav.ts @@ -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', + }, + ], }, ];