切换模式
config 配置文件
修改默认config.mts 新建config文件夹 →index.mts文件。
ts
import { Search } from './search'
import { defineConfig } from 'vitepress'
// import { socialLinks } from './socialLinks'
import { vite } from './vite'
import { nav } from './nav'
import { sidebar } from './sidebar'
import { footer } from './footer'
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: '小咸鱼',
description: '文档&笔记',
base: '/',
lang: 'zh-CN',
assetsDir: 'static',
themeConfig: {
logo: '/images/logo.svg',
search: Search,
footer: footer,
// https://vitepress.dev/reference/default-theme-config
nav: nav,
sidebar: sidebar,
// socialLinks: socialLinks,
outline: {
level: 2,
label: '页面导航'
},
docFooter: {
prev: '上一页',
next: '下一页'
},
darkModeSwitchLabel: '切换模式',
lightModeSwitchTitle: '切换模式', //鼠标悬停提示文字
darkModeSwitchTitle: '切换模式', //鼠标悬停提示文字
sidebarMenuLabel: '菜单',
returnToTopLabel: '返回顶部',
externalLinkIcon: false //是否在 markdown 中的外部链接旁显示外部链接图标。
},
vite: vite
})导航配置
ts
// config/nav.ts
export const nav = [
{ text: '首页', link: '/' },
{
text: '前端常用',
items: [
{
items: [
{ text: 'UI组件库', link: '/frontend/ui' },
{ text: '实用插件', link: '/frontend/plugin' },
{ text: '后台管理', link: '/frontend/admin-template' },
{ text: '文本辑器', link: '/frontend/editor' }
]
},
{
items: [
{ text: '表格组件', link: '/frontend/table' },
{ text: 'charts图表', link: '/frontend/charts' },
{ text: '矢量图标', link: '/frontend/icons' }
]
}
]
},
{
text: '多媒体',
items: [
{ text: '图片插件', link: '/media/images' },
{ text: '动画插件', link: '/media/animate' },
{ text: '音频播放', link: '/media/audio' },
{ text: '视频播放', link: '/media/video' }
]
},
{
text: '工具大全',
items: [
{ text: 'IDE工具', link: '/tools/ide' },
{ text: 'adobe全家桶', link: '/tools/adobe' }
]
},
{
text: '收藏笔记',
link: '/notes/note'
}
]侧边栏配置 (可自动生成)
ts
// config/sidebar.ts
export const sidebar = {
'/frontend/': [
{
text: 'Vue组件库',
collapsed: false,
base: '/frontend/',
items: [
{ text: 'UI组件库', link: 'ui' },
{ text: '实用插件', link: 'plugin' },
{ text: '后台管理', link: 'admin-template' },
{ text: '文本编辑', link: 'editor' }
]
},
{
text: '通用插件',
base: '/frontend/',
items: [
{ text: '表格组件', link: 'table' },
{ text: 'charts图表', link: 'charts' },
{ text: '矢量图标', link: 'icons' }
]
}
],
'/media/': {
base: '/media/',
items: [
{ text: '图片插件', link: 'images' },
{ text: '动画插件', link: 'animate' },
{ text: '音频播放', link: 'audio' },
{ text: '视频播放', link: 'video' }
]
},
'/tools/': {
base: '/tools/',
items: [
{ text: 'IDE工具', link: 'ide' },
{ text: 'adobe全家桶', link: 'adobe' }
]
}
}本地搜索配置
ts
// search.ts
import { DefaultTheme } from 'vitepress/theme'
interface ISearch {
provider: 'local'
options?: DefaultTheme.LocalSearchOptions
}
export const Search: ISearch = {
provider: 'local',
options: {
locales: {
root: {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档'
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: 'ESC关闭'
}
}
}
}
}
}
}sociaLink 配置
ts
// config/sociaLink.ts
import { QQ } from '../common/index'
export const socialLinks = [
// { icon: 'github', link: 'https://github.com/vuejs/vitepress' },
{
icon: {
svg: '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M511.500488 512.499512m-511.500488 0a511.500488 511.500488 0 1 0 1023.000976 0 511.500488 511.500488 0 1 0-1023.000976 0Z" fill="#1BC1FA" p-id="31088"></path><path d="M784.234146 572.440976c8.178014 0 16.273108 0.253752 24.282287 0.728288-16.961436-38.434466-42.247742-69.886751-58.977405-90.331785 2.822244-8.482716 11.30496-56.536788-25.443153-90.453666v-2.827239c0-132.850263-96.103149-231.785647-214.822213-231.785647-118.717065 0-214.82521 96.107145-214.825209 231.785647v2.827239c-33.915879 33.915879-25.437159 81.969951-19.782681 90.453666-25.444152 28.265397-73.49223 87.62343-76.320469 155.461182 0 16.961436 2.827239 45.226833 11.305959 56.531794 11.305959 14.133198 39.570357-2.827239 62.186272-48.054073 5.650482 19.788675 19.78368 53.709549 50.876316 93.281905-50.876316 11.302962-65.009514 62.186271-48.049077 90.450669 11.305959 19.788675 39.570357 33.920874 87.624429 33.920874 78.496343 0 115.815899-19.378076 134.378771-35.711126C492.644901 814.680414 490.520976 800.136617 490.520976 785.233171c0-117.522232 131.500581-212.792195 293.71317-212.792195z" fill="#ffffff" p-id="31089" data-spm-anchor-id="a313x.search_index.0.i88.59253a81ue5uo9" class="selected"></path><path d="M514.925143 819.204995c5.654478 0 11.309955 2.82624 14.132199 5.649483 16.960437 16.960437 53.709549 39.575352 138.50674 39.575352 48.054072 0 76.320468-16.960437 87.625428-33.920874 16.960437-28.264398 2.827239-79.147707-48.054072-90.450669 31.092636-39.572355 45.225834-73.493229 50.881311-93.281905 19.787676 45.226833 50.881311 62.18727 62.186271 48.054073 2.827239-11.30496 5.650482-39.570357 5.650482-56.531794-1.93511-23.223321-8.508691-45.121936-17.337069-65.128398-8.009179-0.475536-16.104273-0.729288-24.282287-0.729287-162.212589 0-293.713171 95.269963-293.71317 212.792195 0 14.903446 2.123926 29.447243 6.147996 43.485533a88.18688 88.18688 0 0 0 4.122973-3.864226c2.827239-2.823243 8.481717-5.649483 14.133198-5.649483z" fill="#FFFFFF" opacity=".4"></path></svg>'
},
link: `http://wpa.qq.com/msgrd?v=3&uin=${QQ}&site=qq&menu=yes`
}
]Vite 配置
ts
// config/vite.ts
import UnoCSS from 'unocss/vite'
export const vite = {
plugins: [UnoCSS()],
server: {
host: '0.0.0.0'
},
build: {
minify: true // 是否压缩代码
}
}