Skip to content

阮喵喵自用的vitepress预设配置

设计初衷

为了替换掉之前的vuepress预设配置。之前的vuepress预设配置导致我命名md文件很不舒服。

安装

bash
pnpm i -D @ruan-cat/vitepress-preset-config vue vitepress vitepress-demo-plugin

必须安装对等依赖

必须安装以下对等依赖:

  • vitepress
  • vitepress-demo-plugin
  • vue

git提交忽略配置 0.13.0

从 0.13.0 版本开始,在使用预设配置打包文档项目时,会在文档根目录内,额外生成 .vercel 目录,以便于 vercel 平台的部署。在使用命令行直接完成 vercel 平台部署时,额外整理好的 .vercel 目录能有效的完成快速部署。

因此,在文档项目内,或者是其他的.gitignore内,至少要包含.vercel目录,该目录应该要被忽略提交。

txt
.vercel

简易使用

用户配置

config.mts
ts
import { 
setUserConfig
,
setGenerateSidebar
,
addChangelog2doc
} from "@ruan-cat/vitepress-preset-config/config";
// 为文档添加自动生成的changelog
addChangelog2doc
({
// 设置changelog的目标文件夹
target
: "./docs",
// 设置changelog顶部的yaml数据。通常是排序
data
: {
order
: 1000,
dir
: {
order
: 1000,
}, }, }); const
userConfig
=
setUserConfig
({
title
: "阮喵喵的01星球笔记",
description
: "阮喵喵在01星球内的一些公用文档",
themeConfig
: {
socialLinks
: [
{
icon
: "github",
link
: "https://github.com/ruan-cat",
}, ], }, }); // @ts-ignore
userConfig
.
themeConfig
.
sidebar
=
setGenerateSidebar
({
documentRootPath
: "./docs",
}); export default
userConfig
;

侧边栏配置必须单独赋值

经过测试,目前发现侧边栏数组只能在手动赋值的时候才生效。

主题配置

theme/index.ts
ts
import { 
defineRuancatPresetTheme
} from "@ruan-cat/vitepress-preset-config/theme";
// 增加用户自定义样式 import "./style.css"; export default
defineRuancatPresetTheme
();

提供功能

本预设默认提供以下功能:

图片放大预览

点击以下图片,即可放大预览

2025-07-03-01-20-20