代码精简
更新时间: 8/31/2025, 1:51:17 PM
在.vitepress
目录新建config
文件夹,并新建index.ts
文件
md
.
├─ docs
│ ├─ .vitepress
│ │ └─ config.mts
│ │ └─ configs <- 配置文件夹
│ │ └─ index.ts
│ └─ index.md
└─ node_modules
然后复制粘贴到index.ts
并保存下面代码
ts
/* 统一出口,方便以后继续拆分 */
export * from './nav'
export * from './sidebar'
export * from './socialLinks'
然后再新建nav.ts``sidebar.ts``socialLinks.ts
文件
ts
import type { DefaultTheme } from 'vitepress'
export const nav: DefaultTheme.Config['nav'] = [
{ text: '主页', link: '/' },
{ text: '知识库', link: '/docs/01.知识库/wiki栏目说明' },
{ text: '工具箱', link: '/docs/00.杂七杂八/工具索引' },
{ text: '项目', link: '/docs/99.项目库/项目栏目说明' },
{
text: '其他',
items: [
{ text: '团队介绍', link: '/docs/00.杂七杂八/团队介绍' },
{ text: '发展脉络', link: '/docs/00.杂七杂八/发展脉络' },
{ text: '登の窝', link: 'http://doc.rseg.club/' },
{ text: '筱莫的博客', link: 'https://blog.mostu.cn/' }
]
},
{
text: '博物馆',
items: [{ text: '栏目说明', link: '/docs/98.博物馆/博物馆栏目说明' }]
}
]
ts
import type { DefaultTheme } from 'vitepress'
export const sidebar: DefaultTheme.Config['sidebar'] = [
{
text: '「 📚 知识库」',
items: [
{
text: 'VitePress',
collapsed: false,
items: [
{ text: '常用指令', link: '/docs/01.知识库/01.VitePress/00.常用指令' },
{ text: '实践页面', link: '/docs/01.知识库/01.VitePress/01.实践页面' },
{ text: '侧边栏与多级侧边栏', link: '/docs/01.知识库/01.VitePress/02.多级侧边栏' },
{ text: '可折叠侧边栏组', link: '/docs/01.知识库/01.VitePress/03.可折叠侧边栏' },
{ text: '页脚编辑', link: '/docs/01.知识库/01.VitePress/04.页脚编辑' },
{ text: '标题徽章', link: '/docs/01.知识库/01.VitePress/05.标题徽章' },
{ text: '团队页面', link: '/docs/01.知识库/01.VitePress/06.团队页面' },
{ text: '最后编辑时间', link: '/docs/01.知识库/01.VitePress/07.最后编辑时间' },
{ text: '嵌入视频播放器', link: '/docs/01.知识库/01.VitePress/08.嵌入视频播放页' },
{ text: '嵌入音乐播放器', link: '/docs/01.知识库/01.VitePress/09.嵌入音乐播放器' },
{ text: '首页文章自动更新', link: '/docs/01.知识库/01.VitePress/10.首页文章自动更新' },
{ text: '主题色', link: '/docs/01.知识库/01.VitePress/11.主题色' },
{ text: 'H1标题颜色', link: '/docs/01.知识库/01.VitePress/12.H1标题颜色' },
{ text: '去除链接下划线', link: '/docs/01.知识库/01.VitePress/13.去除链接下划线' },
{ text: '彩虹背景动画', link: '/docs/01.知识库/01.VitePress/14.彩虹背景动画' },
{ text: '引用颜色', link: '/docs/01.知识库/01.VitePress/15.引用颜色' },
{ text: '容器颜色', link: '/docs/01.知识库/01.VitePress/16.容器颜色' },
{ text: '导航栏毛玻璃', link: '/docs/01.知识库/01.VitePress/17.导航栏毛玻璃' },
{ text: '代码块', link: '/docs/01.知识库/01.VitePress/18.代码块' },
{ text: '代码组', link: '/docs/01.知识库/01.VitePress/19.代码组' },
{ text: '链接卡片', link: '/docs/01.知识库/01.VitePress/20.链接卡片' }
]
}
]
},
{
text: '「 💼 项目」',
items: [
{ text: '▶︎ 栏目说明', link: '/docs/99.项目库/项目栏目说明' },
{
text: '💡 最新想法',
collapsed: true,
items: [{ text: '基岩版服务器', link: '/docs/99.项目库/01.想开一个基岩版服务器' }]
},
{
text: '📂 工作进度',
collapsed: true,
items: [
{ text: 'Java版服务器', link: '/docs/99.项目库/02.Java版服务器现状' },
{ text: '研究VitePress插件', link: '/docs/99.项目库/03.研究VitePress插件' }
]
}
]
},
{
text: '「 💾 博物馆」',
items: [
{ text: '▶︎ 栏目说明', link: '/docs/98.博物馆/博物馆栏目说明' },
{
text: '服务器相关',
collapsed: true,
items: [
{ text: 'GeDK服务器规定', link: '/docs/98.博物馆/01.服务器/01.GeDK服务器规定' },
{ text: 'GeDK服规试行版', link: '/docs/98.博物馆/01.服务器/02.GeDK服规试行版' },
{ text: '服务器部分可用指令', link: '/docs/98.博物馆/01.服务器/03.服务器部分可用指令' }
]
}
]
}
]
ts
import type { DefaultTheme } from 'vitepress'
export const socialLinks: DefaultTheme.Config['socialLinks'] = [
{ icon: 'github', link: 'https://github.com/GeminiAlpha-1' },
{
icon: {
svg: '<svg t="1755621330254" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9837" width="200" height="200"><path d="M390 489.68c-7.3-2.62-13.9-4-17.86-2.84a49.34 49.34 0 0 0 7.78 10.24z" fill="#946CE6" p-id="9838"></path><path d="M845.08 658.82c-8.86-5.56-18.34-6.28-33.42-3.52-0.7 0.12-1.38 0-2 0a7.64 7.64 0 0 1-1.18 0c-22 1.74-39.88-18.74-43.36-23.1a17.1 17.1 0 0 1 2.74-24 17.3 17.3 0 0 1 24 2.72 46 46 0 0 0 7.4 7.1c21.58-47.2 35.18-101.52-2.54-156.64-61.38-89.74-145.84-134.44-258.22-136.66-34-0.66-74.54 0.94-117.58 2.62-99.84 4-170.66 5.48-210.48-6.76-0.42 0-0.82-0.3-1.26-0.44-11.46-3.66-20.46-8.48-26.54-14.86a17.08 17.08 0 0 1 24.68-23.6 20.44 20.44 0 0 0 3 2.2c15.06-13.2 37.48-24.36 58-34.34l6.76-3.28a269.88 269.88 0 0 0-63.84 15.72c-30.16 11.52-44 23.62-47.04 31.1-12.78 32 44.92 60.52 70.36 71.28 35.48 15 145.38 36 192.92 40.7 30 2.94 48.7 12 59.52 19.18 32-20.26 57.08-35.16 64.48-39.5 7.66-5.3 18.58-2 23.36 6a17.1 17.1 0 0 1-6 23.4c-91.5 53.86-234.74 148.82-254.58 190.04-6.92 15.82-10.2 44.96 4.24 73.26 20 39.16 69.16 68.32 142.2 84.28 162 35.44 276.74-36.46 302.84-72.6a37.08 37.08 0 0 1-7.02-6.66A17.08 17.08 0 0 1 783.8 662c3.44 4.18 21.52 9.68 32.34 12.98 5.84 1.8 11.7 3.6 17.12 5.52 8 2.78 16.74 2.62 22.8-0.42a10 10 0 0 0 5.38-5.64c1.16-3.8-4.62-8.2-16.36-15.62zM416 616a18.16 18.16 0 1 1 18.16-18.18A18.16 18.16 0 0 1 416 616z m171.24 54.48a18.16 18.16 0 1 1 18.16-18.18 18.16 18.16 0 0 1-18.16 18.14z" fill="#946CE6" p-id="9839"></path><path d="M870.4 0H153.6A153.58 153.58 0 0 0 0 153.6v716.8A153.58 153.58 0 0 0 153.6 1024h716.8a153.58 153.58 0 0 0 153.6-153.6V153.6A153.58 153.58 0 0 0 870.4 0z m23.72 684.44A43.68 43.68 0 0 1 872.26 710l-0.8 0.42c-14.24 7.18-32.74 8-49.46 2.16-5.06-1.8-10.46-3.44-15.86-5.08l-11.38-3.6c-12.12 19.7-37.08 41.78-72.24 60.28-63.14 33.24-158.6 54.96-269.12 30.84-84.58-18.5-140.2-52.88-165.34-102.18-19.84-38.84-15.5-78.66-4.88-102.98 9.52-19.8 36.38-45.48 69.6-72-8.4-9.72-15.88-21.76-15.56-34a30 30 0 0 1 14-24.52c22.56-15.38 52.76-2.96 71.24 7.56 10.64-7.28 21.24-14.42 31.56-21.2a117.18 117.18 0 0 0-29.82-6.54c-45-4.46-161.6-25.8-202.9-43.28-100.36-42.44-98.72-90.46-88.8-115.34C150 236.4 248 210.2 293.26 211.22c21.54 0.48 34.64 7.12 39.04 19.74 8.38 21.62-16.96 33.8-49.12 49.46-8.42 4-18.12 8.82-27.24 13.76 45.74 3.78 113.02 1.16 163.58-0.84 43.54-1.74 84.68-3.36 119.58-2.68 122.54 2.44 218.7 53.34 285.78 151.54 43.84 64.14 30.96 128.7 10.72 178a59.5 59.5 0 0 1 26 8.62c15.6 9.84 41.62 26.14 32.52 55.62z" fill="#946CE6" p-id="9840"></path></svg>'
},
link: 'https://afdian.com/a/mcooooo'
},
{
icon: {
svg: '<svg t="1755621432320" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10849" width="200" height="200"><path d="M204.288 63.488c-8.704 8.192-16.896 20.48-18.944 26.624-3.584 11.776 12.8 62.464 20.48 62.464S235.52 176.128 235.52 184.32c0 16.384-17.92 26.112-47.104 26.112-34.816 0-104.448 27.648-128.512 51.2-9.216 8.704-26.112 33.792-37.888 56.32L0 358.4v469.504l21.504 40.448c24.576 47.616 35.84 59.392 82.944 84.992l40.96 22.528h722.944l40.96-19.968c51.712-24.576 72.704-45.056 95.744-94.72l17.92-38.4v-231.424l0.512-231.424-17.92-36.352c-9.216-20.48-28.16-47.104-42.496-59.904-31.232-30.208-86.528-54.272-122.368-54.272-54.272 0-65.024-22.528-26.624-57.856 20.48-18.432 23.04-25.088 23.04-45.568 0-19.968-3.584-28.16-16.896-41.984-9.216-9.216-22.528-16.896-29.696-16.896-11.776 0-34.304 9.216-40.448 16.896-1.536 1.536-35.84 35.328-75.776 74.24l-73.216 71.168-83.456-0.512c-45.568 0-88.064-2.56-93.696-4.608-5.632-2.56-38.4-31.232-72.704-65.024C249.856 40.448 235.008 32.256 204.288 63.488z m652.8 262.656c5.12 0.512 19.968 9.216 31.744 20.48l21.504 19.968 1.536 217.088c1.024 197.12 0.512 218.112-8.704 236.032-14.336 27.136-34.816 40.448-65.536 41.984-14.336 0.512-173.568 0.512-353.28 0l-326.144-1.536-45.056-45.056V373.248l20.992-22.528c15.872-17.92 25.6-23.552 41.984-25.088 16.384-1.024 634.88-0.512 680.96 0.512z" fill="#FB7299" p-id="10850"></path><path d="M279.04 502.272c-20.48 22.016-20.992 25.088-20.992 66.56 0 39.936 1.024 44.544 17.92 64 29.184 33.28 55.808 32.256 84.48-2.56 11.264-12.8 12.8-22.016 13.312-64 0-47.104-0.512-48.64-19.968-68.096-27.136-27.648-47.616-26.112-74.752 4.096z m393.216-3.584c-18.944 18.944-19.968 20.992-19.968 69.12 0 47.616 0.512 49.664 18.432 67.072 24.576 23.552 35.84 26.624 58.368 13.824 29.184-16.896 39.936-43.52 36.864-90.624-2.56-35.328-4.608-41.984-22.016-59.904-25.088-25.6-45.568-25.6-71.68 0.512z" fill="#FB7299" p-id="10851"></path></svg>'
},
link: 'https://space.bilibili.com/1323019347'
}
]
精简后的config.mts
ts
import { defineConfig } from 'vitepress'
import { nav, sidebar, socialLinks } from './configs'
export default defineConfig({
base: '/',
head: [['link', { rel: 'icon', href: '/logo.png' }]],
title: 'MCOO墨客小筑',
description: 'A VitePress Site',
appearance: true,
lastUpdated: true,
markdown: {
config: (md) => {
md.set({ html: true })
}
},
themeConfig: {
outlineTitle: '文章目录',
outline: [2, 6],
logo: '/logo2.svg',
nav, // ← 已拆分
sidebar, // ← 已拆分
socialLinks, // ← 已拆分
footer: {
copyright: 'Copyright © 2020 Alioth Dream Studios'
},
search: {
provider: 'local',
options: {
translations: {
button: {
buttonText: '搜索内容',
buttonAriaLabel: '搜索内容'
},
modal: {
noResultsText: '无结果',
resetButtonTitle: '清除',
footer: {
selectText: '选择',
navigateText: '切换'
}
}
}
}
}
}
})