@ruan-cat/vitepress-preset-config 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.mts +13 -3
- package/dist/config.mjs +48 -17
- package/package.json +2 -2
- package/src/config.mts +74 -25
- package/src/type.ts +9 -0
package/dist/config.d.mts
CHANGED
|
@@ -2,10 +2,20 @@ import * as vitepress_sidebar_types from 'vitepress-sidebar/types';
|
|
|
2
2
|
import { UserConfig, DefaultTheme } from 'vitepress';
|
|
3
3
|
export { defineConfig } from 'vitepress';
|
|
4
4
|
import { generateSidebar } from 'vitepress-sidebar';
|
|
5
|
-
export { addChangelog2doc } from '@ruan-cat/utils/node-esm';
|
|
5
|
+
export { addChangelog2doc, copyReadmeMd } from '@ruan-cat/utils/node-esm';
|
|
6
6
|
export { withMermaid } from 'vitepress-plugin-mermaid';
|
|
7
7
|
export { default as VitePluginVercel } from 'vite-plugin-vercel';
|
|
8
8
|
|
|
9
|
+
/** 阮喵喵针对文档行为的配置 */
|
|
10
|
+
interface RuanCatConfig {
|
|
11
|
+
plugins?: {
|
|
12
|
+
llmstxt?: boolean;
|
|
13
|
+
gitChangelog?: boolean;
|
|
14
|
+
gitChangelogMarkdownSection?: boolean;
|
|
15
|
+
vitePluginVercel?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
10
20
|
/**
|
|
11
21
|
* 设置自动生成侧边栏的配置
|
|
@@ -13,6 +23,6 @@ type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
|
13
23
|
*/
|
|
14
24
|
declare function setGenerateSidebar(options?: VitePressSidebarOptions): vitepress_sidebar_types.Sidebar;
|
|
15
25
|
/** 设置vitepress主配置 */
|
|
16
|
-
declare function setUserConfig(config?: UserConfig<DefaultTheme.Config
|
|
26
|
+
declare function setUserConfig(config?: UserConfig<DefaultTheme.Config>, ruanCatConfig?: RuanCatConfig): UserConfig<DefaultTheme.Config>;
|
|
17
27
|
|
|
18
|
-
export { setGenerateSidebar, setUserConfig };
|
|
28
|
+
export { type RuanCatConfig, setGenerateSidebar, setUserConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-p
|
|
|
5
5
|
import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
6
6
|
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
7
7
|
import consola from "consola";
|
|
8
|
-
import { addChangelog2doc, hasChangelogMd } from "@ruan-cat/utils/node-esm";
|
|
8
|
+
import { addChangelog2doc, hasChangelogMd, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
9
9
|
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
10
10
|
import llmstxt from "vitepress-plugin-llms";
|
|
11
11
|
import { withMermaid } from "vitepress-plugin-mermaid";
|
|
@@ -41,6 +41,22 @@ function getMergeSidebarOptions(options) {
|
|
|
41
41
|
function setGenerateSidebar(options) {
|
|
42
42
|
return generateSidebar(getMergeSidebarOptions(options));
|
|
43
43
|
}
|
|
44
|
+
var defaultLlmstxt = llmstxt();
|
|
45
|
+
var defaultGitChangelog = GitChangelog({
|
|
46
|
+
// 填写在此处填写您的仓库链接
|
|
47
|
+
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
48
|
+
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
49
|
+
maxGitLogCount: 10
|
|
50
|
+
});
|
|
51
|
+
var defaultGitChangelogMarkdownSection = GitChangelogMarkdownSection();
|
|
52
|
+
var defaultVitePluginVercel = VitePluginVercel();
|
|
53
|
+
var defaultVitePlugins = [
|
|
54
|
+
defaultLlmstxt,
|
|
55
|
+
defaultGitChangelog,
|
|
56
|
+
defaultGitChangelogMarkdownSection,
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
defaultVitePluginVercel
|
|
59
|
+
];
|
|
44
60
|
var defaultUserConfig = {
|
|
45
61
|
title: "\u8BF7\u586B\u5199\u6709\u610F\u4E49\u7684\u6807\u9898",
|
|
46
62
|
description: "\u8BF7\u586B\u5199\u6709\u610F\u4E49\u7684\u63CF\u8FF0",
|
|
@@ -71,21 +87,8 @@ var defaultUserConfig = {
|
|
|
71
87
|
server: {
|
|
72
88
|
open: true
|
|
73
89
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
llmstxt(),
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
GitChangelog({
|
|
80
|
-
// 填写在此处填写您的仓库链接
|
|
81
|
-
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
82
|
-
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
83
|
-
maxGitLogCount: 10
|
|
84
|
-
}),
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
GitChangelogMarkdownSection(),
|
|
87
|
-
VitePluginVercel()
|
|
88
|
-
],
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
plugins: defaultVitePlugins,
|
|
89
92
|
optimizeDeps: {
|
|
90
93
|
exclude: [
|
|
91
94
|
"@nolebase/vitepress-plugin-breadcrumbs/client",
|
|
@@ -135,14 +138,42 @@ function handleChangeLog(userConfig) {
|
|
|
135
138
|
}
|
|
136
139
|
nav.push({ text: "\u66F4\u65B0\u65E5\u5FD7", link: "/CHANGELOG.md" });
|
|
137
140
|
}
|
|
138
|
-
|
|
141
|
+
var defaultRuanCatConfig = {
|
|
142
|
+
plugins: {
|
|
143
|
+
llmstxt: true,
|
|
144
|
+
gitChangelog: true,
|
|
145
|
+
gitChangelogMarkdownSection: true,
|
|
146
|
+
vitePluginVercel: true
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function handlePlugins(userConfig, ruanCatConfig = defaultRuanCatConfig) {
|
|
150
|
+
var _a, _b, _c, _d;
|
|
151
|
+
let resPlugins = [];
|
|
152
|
+
ruanCatConfig = merge({}, cloneDeep(defaultRuanCatConfig), ruanCatConfig);
|
|
153
|
+
if ((_a = ruanCatConfig == null ? void 0 : ruanCatConfig.plugins) == null ? void 0 : _a.llmstxt) {
|
|
154
|
+
resPlugins.push(defaultLlmstxt);
|
|
155
|
+
}
|
|
156
|
+
if ((_b = ruanCatConfig == null ? void 0 : ruanCatConfig.plugins) == null ? void 0 : _b.gitChangelog) {
|
|
157
|
+
resPlugins.push(defaultGitChangelog);
|
|
158
|
+
}
|
|
159
|
+
if ((_c = ruanCatConfig == null ? void 0 : ruanCatConfig.plugins) == null ? void 0 : _c.gitChangelogMarkdownSection) {
|
|
160
|
+
resPlugins.push(defaultGitChangelogMarkdownSection);
|
|
161
|
+
}
|
|
162
|
+
if ((_d = ruanCatConfig == null ? void 0 : ruanCatConfig.plugins) == null ? void 0 : _d.vitePluginVercel) {
|
|
163
|
+
resPlugins.push(defaultVitePluginVercel);
|
|
164
|
+
}
|
|
165
|
+
userConfig.vite.plugins = resPlugins;
|
|
166
|
+
}
|
|
167
|
+
function setUserConfig(config, ruanCatConfig = defaultRuanCatConfig) {
|
|
139
168
|
const resUserConfig = merge({}, cloneDeep(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
140
169
|
handleChangeLog(resUserConfig);
|
|
170
|
+
handlePlugins(resUserConfig, ruanCatConfig);
|
|
141
171
|
return resUserConfig;
|
|
142
172
|
}
|
|
143
173
|
export {
|
|
144
174
|
VitePluginVercel,
|
|
145
175
|
addChangelog2doc,
|
|
176
|
+
copyReadmeMd,
|
|
146
177
|
defineConfig,
|
|
147
178
|
setGenerateSidebar,
|
|
148
179
|
setUserConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/vitepress-preset-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "用于给大多数的vitepress项目提供一个预设的配置文件。",
|
|
5
5
|
"homepage": "https://vitepress-preset.ruancat6312.top",
|
|
6
6
|
"types": "./src/config.mts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"vitepress-plugin-mermaid": "^2.0.17",
|
|
24
24
|
"vitepress-sidebar": "^1.31.1",
|
|
25
25
|
"vue": "^3.5.13",
|
|
26
|
-
"@ruan-cat/utils": "^4.
|
|
26
|
+
"@ruan-cat/utils": "^4.9.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/lodash-es": "^4.17.12",
|
package/src/config.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type PluginOption } from "vite";
|
|
1
2
|
import { defineConfig, type DefaultTheme, type UserConfig } from "vitepress";
|
|
3
|
+
export { defineConfig };
|
|
2
4
|
import { generateSidebar, withSidebar } from "vitepress-sidebar";
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
import { type RuanCatConfig } from "./type.ts";
|
|
7
|
+
export { RuanCatConfig };
|
|
5
8
|
|
|
6
9
|
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
7
10
|
import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
@@ -9,8 +12,8 @@ import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
|
9
12
|
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
10
13
|
import consola from "consola";
|
|
11
14
|
|
|
12
|
-
import { addChangelog2doc, hasChangelogMd } from "@ruan-cat/utils/node-esm";
|
|
13
|
-
export { addChangelog2doc };
|
|
15
|
+
import { addChangelog2doc, hasChangelogMd, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
16
|
+
export { addChangelog2doc, copyReadmeMd };
|
|
14
17
|
|
|
15
18
|
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
16
19
|
|
|
@@ -84,6 +87,29 @@ export function setGenerateSidebar(options?: VitePressSidebarOptions) {
|
|
|
84
87
|
return generateSidebar(getMergeSidebarOptions(options));
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
/** @see https://github.com/okineadev/vitepress-plugin-llms */
|
|
91
|
+
const defaultLlmstxt = llmstxt();
|
|
92
|
+
|
|
93
|
+
const defaultGitChangelog = GitChangelog({
|
|
94
|
+
// 填写在此处填写您的仓库链接
|
|
95
|
+
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
96
|
+
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
97
|
+
maxGitLogCount: 10,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const defaultGitChangelogMarkdownSection = GitChangelogMarkdownSection();
|
|
101
|
+
|
|
102
|
+
const defaultVitePluginVercel = VitePluginVercel();
|
|
103
|
+
|
|
104
|
+
/** 默认的vite插件 */
|
|
105
|
+
const defaultVitePlugins: PluginOption[] = [
|
|
106
|
+
defaultLlmstxt,
|
|
107
|
+
defaultGitChangelog,
|
|
108
|
+
defaultGitChangelogMarkdownSection,
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
defaultVitePluginVercel,
|
|
111
|
+
];
|
|
112
|
+
|
|
87
113
|
/** 默认用户配置 */
|
|
88
114
|
const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
89
115
|
title: "请填写有意义的标题",
|
|
@@ -124,24 +150,8 @@ const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
|
124
150
|
open: true,
|
|
125
151
|
},
|
|
126
152
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
llmstxt(),
|
|
131
|
-
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
GitChangelog({
|
|
134
|
-
// 填写在此处填写您的仓库链接
|
|
135
|
-
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
136
|
-
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
137
|
-
maxGitLogCount: 10,
|
|
138
|
-
}),
|
|
139
|
-
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
GitChangelogMarkdownSection(),
|
|
142
|
-
|
|
143
|
-
VitePluginVercel(),
|
|
144
|
-
],
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
plugins: defaultVitePlugins,
|
|
145
155
|
|
|
146
156
|
optimizeDeps: {
|
|
147
157
|
exclude: [
|
|
@@ -210,17 +220,56 @@ function handleChangeLog(userConfig: UserConfig<DefaultTheme.Config>) {
|
|
|
210
220
|
nav.push({ text: "更新日志", link: "/CHANGELOG.md" });
|
|
211
221
|
}
|
|
212
222
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
223
|
+
const defaultRuanCatConfig: RuanCatConfig = {
|
|
224
|
+
plugins: {
|
|
225
|
+
llmstxt: true,
|
|
226
|
+
gitChangelog: true,
|
|
227
|
+
gitChangelogMarkdownSection: true,
|
|
228
|
+
vitePluginVercel: true,
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/** 处理插件配置 */
|
|
233
|
+
function handlePlugins(
|
|
234
|
+
//
|
|
235
|
+
userConfig: UserConfig<DefaultTheme.Config>,
|
|
236
|
+
ruanCatConfig: RuanCatConfig = defaultRuanCatConfig,
|
|
237
|
+
) {
|
|
238
|
+
let resPlugins: PluginOption[] = [];
|
|
239
|
+
|
|
240
|
+
ruanCatConfig = merge({}, cloneDeep(defaultRuanCatConfig), ruanCatConfig);
|
|
241
|
+
|
|
242
|
+
if (ruanCatConfig?.plugins?.llmstxt) {
|
|
243
|
+
resPlugins.push(defaultLlmstxt);
|
|
244
|
+
}
|
|
245
|
+
if (ruanCatConfig?.plugins?.gitChangelog) {
|
|
246
|
+
resPlugins.push(defaultGitChangelog);
|
|
247
|
+
}
|
|
248
|
+
if (ruanCatConfig?.plugins?.gitChangelogMarkdownSection) {
|
|
249
|
+
resPlugins.push(defaultGitChangelogMarkdownSection);
|
|
250
|
+
}
|
|
251
|
+
if (ruanCatConfig?.plugins?.vitePluginVercel) {
|
|
252
|
+
// @ts-ignore
|
|
253
|
+
resPlugins.push(defaultVitePluginVercel);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
userConfig.vite.plugins = resPlugins;
|
|
258
|
+
}
|
|
216
259
|
|
|
217
260
|
/** 设置vitepress主配置 */
|
|
218
|
-
export function setUserConfig(
|
|
261
|
+
export function setUserConfig(
|
|
262
|
+
config?: UserConfig<DefaultTheme.Config>,
|
|
263
|
+
ruanCatConfig: RuanCatConfig = defaultRuanCatConfig,
|
|
264
|
+
): UserConfig<DefaultTheme.Config> {
|
|
219
265
|
/** 最终的用户数据 */
|
|
220
266
|
const resUserConfig = merge({}, cloneDeep(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
221
267
|
|
|
222
268
|
// 增加导航栏
|
|
223
269
|
handleChangeLog(resUserConfig);
|
|
224
270
|
|
|
271
|
+
// 设置插件
|
|
272
|
+
handlePlugins(resUserConfig, ruanCatConfig);
|
|
273
|
+
|
|
225
274
|
return resUserConfig;
|
|
226
275
|
}
|