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

简易使用

用户配置

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
();