@ruan-cat/vitepress-preset-config 1.4.0 → 2.0.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 +42 -1
- package/dist/config.mjs +68 -40
- package/dist/theme.d.mts +0 -2
- package/dist/theme.mjs +2 -1
- package/package.json +1 -1
- package/src/config/index.ts +4 -0
- package/src/config/plugins.ts +53 -0
- package/src/config/teek.ts +59 -0
- package/src/config.mts +28 -75
- package/src/index.ts +6 -0
- package/src/theme.ts +2 -1
- package/src/types.ts +49 -0
package/dist/config.d.mts
CHANGED
|
@@ -2,8 +2,49 @@ 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
|
+
import llmstxt from 'vitepress-plugin-llms';
|
|
6
|
+
import { GitChangelog, GitChangelogMarkdownSectionOptions } from '@nolebase/vitepress-plugin-git-changelog/vite';
|
|
7
|
+
import { defineTeekConfig } from 'vitepress-theme-teek/config';
|
|
5
8
|
export { addChangelog2doc, copyReadmeMd } from '@ruan-cat/utils/node-esm';
|
|
6
9
|
|
|
10
|
+
type LlmstxtSettings = NonNullable<Parameters<typeof llmstxt>[0]>;
|
|
11
|
+
type GitChangelogOptions = NonNullable<Parameters<typeof GitChangelog>[0]>;
|
|
12
|
+
type TeekConfigOptions = NonNullable<Parameters<typeof defineTeekConfig>[0]>;
|
|
13
|
+
/**
|
|
14
|
+
* 额外的配置
|
|
15
|
+
* @description
|
|
16
|
+
* 目前主要用于精细化配置 vitepress 的插件
|
|
17
|
+
*/
|
|
18
|
+
interface ExtraConfig {
|
|
19
|
+
/**
|
|
20
|
+
* 即 vite 的 plugins
|
|
21
|
+
* @description
|
|
22
|
+
* vitepress 配置的一系列插件
|
|
23
|
+
*/
|
|
24
|
+
plugins?: {
|
|
25
|
+
/**
|
|
26
|
+
* @description 用于配置 vitepress-plugin-llms 插件
|
|
27
|
+
* @see https://github.com/okineadev/vitepress-plugin-llms
|
|
28
|
+
*/
|
|
29
|
+
llmstxt?: LlmstxtSettings | false;
|
|
30
|
+
/**
|
|
31
|
+
* @description 用于配置 @nolebase/vitepress-plugin-git-changelog 插件
|
|
32
|
+
* @see
|
|
33
|
+
*/
|
|
34
|
+
gitChangelog?: GitChangelogOptions | false;
|
|
35
|
+
/**
|
|
36
|
+
* @description 用于配置 @nolebase/vitepress-plugin-git-changelog-markdown-section 插件
|
|
37
|
+
* @see
|
|
38
|
+
*/
|
|
39
|
+
gitChangelogMarkdownSection?: GitChangelogMarkdownSectionOptions | false;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Teek 主题配置
|
|
43
|
+
* @see https://vp.teek.top/reference/config.html
|
|
44
|
+
*/
|
|
45
|
+
teekConfig?: TeekConfigOptions;
|
|
46
|
+
}
|
|
47
|
+
|
|
7
48
|
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
8
49
|
/**
|
|
9
50
|
* 设置自动生成侧边栏的配置
|
|
@@ -11,6 +52,6 @@ type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
|
11
52
|
*/
|
|
12
53
|
declare function setGenerateSidebar(options?: VitePressSidebarOptions): vitepress_sidebar_types.Sidebar;
|
|
13
54
|
/** 设置vitepress主配置 */
|
|
14
|
-
declare function setUserConfig(config?: UserConfig<DefaultTheme.Config
|
|
55
|
+
declare function setUserConfig(config?: UserConfig<DefaultTheme.Config>, extraConfig?: ExtraConfig): UserConfig<DefaultTheme.Config>;
|
|
15
56
|
|
|
16
57
|
export { setGenerateSidebar, setUserConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
1
|
// src/config.mts
|
|
2
2
|
import { defineConfig } from "vitepress";
|
|
3
3
|
import { generateSidebar } from "vitepress-sidebar";
|
|
4
|
-
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
5
4
|
import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
6
|
-
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
5
|
+
import { merge as merge2, isUndefined, cloneDeep as cloneDeep2 } from "lodash-es";
|
|
7
6
|
import consola from "consola";
|
|
8
7
|
import { addChangelog2doc, hasChangelogMd, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
9
8
|
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
|
|
10
|
+
// src/config/plugins.ts
|
|
11
|
+
import vitepressPluginLlmstxt from "vitepress-plugin-llms";
|
|
12
|
+
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
13
|
+
function isFalse(value) {
|
|
14
|
+
return value === false;
|
|
15
|
+
}
|
|
16
|
+
var defaultGitChangelogOptions = {
|
|
17
|
+
// 填写在此处填写您的仓库链接
|
|
18
|
+
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
19
|
+
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
20
|
+
maxGitLogCount: 10
|
|
21
|
+
};
|
|
22
|
+
function getPlugins(extraConfig) {
|
|
23
|
+
const plugins = [];
|
|
24
|
+
const {
|
|
25
|
+
llmstxt,
|
|
26
|
+
gitChangelog = defaultGitChangelogOptions,
|
|
27
|
+
gitChangelogMarkdownSection
|
|
28
|
+
} = (extraConfig == null ? void 0 : extraConfig.plugins) || {};
|
|
29
|
+
if (!isFalse(llmstxt)) {
|
|
30
|
+
plugins.push(vitepressPluginLlmstxt(llmstxt));
|
|
31
|
+
}
|
|
32
|
+
if (!isFalse(gitChangelog)) {
|
|
33
|
+
plugins.push(GitChangelog(gitChangelog));
|
|
34
|
+
}
|
|
35
|
+
if (!isFalse(gitChangelogMarkdownSection)) {
|
|
36
|
+
plugins.push(GitChangelogMarkdownSection(gitChangelogMarkdownSection));
|
|
37
|
+
}
|
|
38
|
+
return plugins;
|
|
39
|
+
}
|
|
40
|
+
function handlePlugins(userConfig, extraConfig) {
|
|
41
|
+
userConfig.vite.plugins = getPlugins(extraConfig);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/config/teek.ts
|
|
12
45
|
import { defineTeekConfig } from "vitepress-theme-teek/config";
|
|
13
|
-
|
|
46
|
+
import { merge, cloneDeep } from "lodash-es";
|
|
47
|
+
var defaultTeekConfig = {
|
|
14
48
|
/** @see https://vp.teek.top/reference/config/global-config.html#sidebartrigger */
|
|
15
49
|
sidebarTrigger: true,
|
|
16
50
|
/**
|
|
@@ -48,7 +82,15 @@ var teekConfig = defineTeekConfig({
|
|
|
48
82
|
hash: false
|
|
49
83
|
// 是否包含哈希值
|
|
50
84
|
}
|
|
51
|
-
}
|
|
85
|
+
};
|
|
86
|
+
function handleTeekConfig(userConfig, extraConfig) {
|
|
87
|
+
const { teekConfig = defaultTeekConfig } = extraConfig ?? {};
|
|
88
|
+
userConfig.extends = defineTeekConfig(merge({}, cloneDeep(defaultTeekConfig), teekConfig));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/config.mts
|
|
92
|
+
import { MermaidPlugin } from "@leelaa/vitepress-plugin-extended";
|
|
93
|
+
import { defineTeekConfig as defineTeekConfig2 } from "vitepress-theme-teek/config";
|
|
52
94
|
var defaultSidebarOptions = {
|
|
53
95
|
// documentRootPath: "src",
|
|
54
96
|
// 侧边栏需要折叠
|
|
@@ -75,13 +117,17 @@ var defaultSidebarOptions = {
|
|
|
75
117
|
debugPrint: false
|
|
76
118
|
};
|
|
77
119
|
function getMergeSidebarOptions(options) {
|
|
78
|
-
return
|
|
120
|
+
return merge2({}, cloneDeep2(defaultSidebarOptions), isUndefined(options) ? {} : options);
|
|
79
121
|
}
|
|
80
122
|
function setGenerateSidebar(options) {
|
|
81
123
|
return generateSidebar(getMergeSidebarOptions(options));
|
|
82
124
|
}
|
|
83
125
|
var defaultUserConfig = {
|
|
84
|
-
|
|
126
|
+
/**
|
|
127
|
+
* 使用默认的 Teek 主题配置
|
|
128
|
+
* 后续会有函数重新设置 Teek 主题配置,并覆盖默认配置
|
|
129
|
+
*/
|
|
130
|
+
extends: defineTeekConfig2(defaultTeekConfig),
|
|
85
131
|
title: "\u8BF7\u586B\u5199\u6709\u610F\u4E49\u7684\u6807\u9898",
|
|
86
132
|
description: "\u8BF7\u586B\u5199\u6709\u610F\u4E49\u7684\u63CF\u8FF0",
|
|
87
133
|
lang: "zh",
|
|
@@ -89,9 +135,7 @@ var defaultUserConfig = {
|
|
|
89
135
|
// srcDir: "./src",
|
|
90
136
|
themeConfig: {
|
|
91
137
|
i18nRouting: true,
|
|
92
|
-
search: {
|
|
93
|
-
provider: "local"
|
|
94
|
-
},
|
|
138
|
+
search: { provider: "local" },
|
|
95
139
|
// https://vitepress.dev/reference/default-theme-config
|
|
96
140
|
nav: [{ text: "\u9996\u9875", link: "/" }],
|
|
97
141
|
outline: {
|
|
@@ -100,35 +144,17 @@ var defaultUserConfig = {
|
|
|
100
144
|
},
|
|
101
145
|
// 自动化侧边栏
|
|
102
146
|
sidebar: setGenerateSidebar(),
|
|
103
|
-
socialLinks: [
|
|
104
|
-
{
|
|
105
|
-
icon: "github",
|
|
106
|
-
link: "https://github.com/ruan-cat"
|
|
107
|
-
}
|
|
108
|
-
]
|
|
147
|
+
socialLinks: [{ icon: "github", link: "https://github.com/ruan-cat" }]
|
|
109
148
|
},
|
|
110
149
|
vite: {
|
|
111
|
-
server: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
GitChangelog({
|
|
121
|
-
// 填写在此处填写您的仓库链接
|
|
122
|
-
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
123
|
-
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
124
|
-
maxGitLogCount: 10
|
|
125
|
-
}),
|
|
126
|
-
// @ts-ignore
|
|
127
|
-
GitChangelogMarkdownSection()
|
|
128
|
-
],
|
|
129
|
-
optimizeDeps: {
|
|
130
|
-
exclude: ["vitepress", "@nolebase/ui"]
|
|
131
|
-
},
|
|
150
|
+
server: { open: true, port: 8080 },
|
|
151
|
+
/**
|
|
152
|
+
* 插件
|
|
153
|
+
* @description
|
|
154
|
+
* 这里留空 插件在 config/plugins.ts 中配置
|
|
155
|
+
*/
|
|
156
|
+
plugins: [],
|
|
157
|
+
optimizeDeps: { exclude: ["vitepress", "@nolebase/ui"] },
|
|
132
158
|
ssr: {
|
|
133
159
|
noExternal: [
|
|
134
160
|
// 如果还有别的依赖需要添加的话,并排填写和配置到这里即可
|
|
@@ -176,9 +202,11 @@ function handleChangeLog(userConfig) {
|
|
|
176
202
|
}
|
|
177
203
|
nav.push({ text: "\u66F4\u65B0\u65E5\u5FD7", link: "/CHANGELOG.md" });
|
|
178
204
|
}
|
|
179
|
-
function setUserConfig(config) {
|
|
180
|
-
const resUserConfig =
|
|
205
|
+
function setUserConfig(config, extraConfig) {
|
|
206
|
+
const resUserConfig = merge2({}, cloneDeep2(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
181
207
|
handleChangeLog(resUserConfig);
|
|
208
|
+
handlePlugins(resUserConfig, extraConfig);
|
|
209
|
+
handleTeekConfig(resUserConfig, extraConfig);
|
|
182
210
|
return resUserConfig;
|
|
183
211
|
}
|
|
184
212
|
export {
|
package/dist/theme.d.mts
CHANGED
|
@@ -22,7 +22,6 @@ declare const defaultTheme: {
|
|
|
22
22
|
extends: vitepress_theme_teek.DefaultThemeType;
|
|
23
23
|
enhanceApp: (options: EnhanceAppContext) => Promise<void>;
|
|
24
24
|
};
|
|
25
|
-
Layout: vue.DefineComponent;
|
|
26
25
|
enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
|
|
27
26
|
};
|
|
28
27
|
/**
|
|
@@ -37,7 +36,6 @@ declare function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParam
|
|
|
37
36
|
extends: vitepress_theme_teek.DefaultThemeType;
|
|
38
37
|
enhanceApp: (options: EnhanceAppContext) => Promise<void>;
|
|
39
38
|
};
|
|
40
|
-
Layout: vue.DefineComponent;
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defaultTheme, defineRuancatPresetTheme };
|
package/dist/theme.mjs
CHANGED
|
@@ -13,7 +13,8 @@ function defaultEnhanceAppPreset({ app, router, siteData }) {
|
|
|
13
13
|
}
|
|
14
14
|
var defaultTheme = {
|
|
15
15
|
extends: Teek,
|
|
16
|
-
|
|
16
|
+
// 有疑惑 根据和 teek 作者的沟通 这个配置可以不写
|
|
17
|
+
// Layout: Teek.Layout,
|
|
17
18
|
enhanceApp({ app, router, siteData }) {
|
|
18
19
|
defaultEnhanceAppPreset({ app, router, siteData });
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type DefaultTheme, type UserConfig } from "vitepress";
|
|
2
|
+
import vitepressPluginLlmstxt from "vitepress-plugin-llms";
|
|
3
|
+
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
4
|
+
|
|
5
|
+
import type { ExtraConfig, GitChangelogOptions } from "../types.ts";
|
|
6
|
+
|
|
7
|
+
function isFalse(value: unknown): value is false {
|
|
8
|
+
return value === false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const defaultGitChangelogOptions: GitChangelogOptions = {
|
|
12
|
+
// 填写在此处填写您的仓库链接
|
|
13
|
+
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
14
|
+
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
15
|
+
maxGitLogCount: 10,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 根据配置 返回插件列表
|
|
20
|
+
* @description
|
|
21
|
+
* 该函数将根据具体的配置 返回插件列表
|
|
22
|
+
*/
|
|
23
|
+
export function getPlugins(extraConfig?: ExtraConfig) {
|
|
24
|
+
const plugins = [];
|
|
25
|
+
const {
|
|
26
|
+
llmstxt,
|
|
27
|
+
gitChangelog = defaultGitChangelogOptions,
|
|
28
|
+
gitChangelogMarkdownSection,
|
|
29
|
+
} = extraConfig?.plugins || {};
|
|
30
|
+
|
|
31
|
+
if (!isFalse(llmstxt)) {
|
|
32
|
+
plugins.push(vitepressPluginLlmstxt(llmstxt));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!isFalse(gitChangelog)) {
|
|
36
|
+
plugins.push(GitChangelog(gitChangelog));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!isFalse(gitChangelogMarkdownSection)) {
|
|
40
|
+
plugins.push(GitChangelogMarkdownSection(gitChangelogMarkdownSection));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return plugins;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 根据用户的额外配置 设置`文档配置`的 vite 插件
|
|
48
|
+
* @description
|
|
49
|
+
*/
|
|
50
|
+
export function handlePlugins(userConfig: UserConfig<DefaultTheme.Config>, extraConfig?: ExtraConfig) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
userConfig.vite.plugins = getPlugins(extraConfig);
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type DefaultTheme, type UserConfig } from "vitepress";
|
|
2
|
+
import { defineTeekConfig } from "vitepress-theme-teek/config";
|
|
3
|
+
import { merge, cloneDeep } from "lodash-es";
|
|
4
|
+
|
|
5
|
+
import type { TeekConfigOptions, ExtraConfig } from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 默认的 Teek 主题配置
|
|
9
|
+
* @see https://vp.teek.top/reference/config.html
|
|
10
|
+
*/
|
|
11
|
+
export const defaultTeekConfig: TeekConfigOptions = {
|
|
12
|
+
/** @see https://vp.teek.top/reference/config/global-config.html#sidebartrigger */
|
|
13
|
+
sidebarTrigger: true,
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 关闭 Teek 主题的首页风格
|
|
17
|
+
* @see https://vp.teek.top/reference/config/global-config.html#teekhome
|
|
18
|
+
*/
|
|
19
|
+
teekHome: false,
|
|
20
|
+
|
|
21
|
+
vitePlugins: {
|
|
22
|
+
/**
|
|
23
|
+
* 关闭 vitepress-plugin-permalink 插件
|
|
24
|
+
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-permalink
|
|
25
|
+
*/
|
|
26
|
+
permalink: false,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 关闭 vitepress-plugin-sidebar-resolve 插件
|
|
30
|
+
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-sidebar-resolve
|
|
31
|
+
*/
|
|
32
|
+
sidebar: false,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 关闭 vitepress-plugin-md-h1 插件
|
|
36
|
+
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-md-h1
|
|
37
|
+
*/
|
|
38
|
+
mdH1: false,
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/** @see https://vp.teek.top/reference/article-config.html#articleshare */
|
|
42
|
+
articleShare: {
|
|
43
|
+
enabled: true, // 是否开启文章链接分享功能
|
|
44
|
+
text: "分享此页面", // 分享按钮文本
|
|
45
|
+
copiedText: "链接已复制", // 复制成功文本
|
|
46
|
+
query: false, // 是否包含查询参数
|
|
47
|
+
hash: false, // 是否包含哈希值
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 根据用户的额外配置 设置`文档配置`的 teek 主题配置
|
|
53
|
+
* @description
|
|
54
|
+
*/
|
|
55
|
+
export function handleTeekConfig(userConfig: UserConfig<DefaultTheme.Config>, extraConfig?: ExtraConfig) {
|
|
56
|
+
const { teekConfig = defaultTeekConfig } = extraConfig ?? {};
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
userConfig.extends = defineTeekConfig(merge({}, cloneDeep(defaultTeekConfig), teekConfig));
|
|
59
|
+
}
|
package/src/config.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
|
7
7
|
|
|
8
8
|
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
9
9
|
import consola from "consola";
|
|
10
|
+
import type { ExtraConfig } from "./types.ts";
|
|
10
11
|
|
|
11
12
|
import { addChangelog2doc, hasChangelogMd, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
12
13
|
export { addChangelog2doc, copyReadmeMd };
|
|
@@ -15,53 +16,14 @@ import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
|
15
16
|
|
|
16
17
|
import llmstxt from "vitepress-plugin-llms";
|
|
17
18
|
|
|
19
|
+
import { defaultTeekConfig, handleTeekConfig, handlePlugins } from "./config/index.ts";
|
|
20
|
+
|
|
18
21
|
/** @see https://vitepress-ext.leelaa.cn/Mermaid.html#扩展-md-插件 */
|
|
19
22
|
import { MermaidPlugin } from "@leelaa/vitepress-plugin-extended";
|
|
20
23
|
|
|
21
24
|
// https://vp.teek.top/guide/quickstart.html#teek-引入
|
|
22
25
|
import { defineTeekConfig } from "vitepress-theme-teek/config";
|
|
23
26
|
|
|
24
|
-
/** Teek 主题配置 */
|
|
25
|
-
const teekConfig = defineTeekConfig({
|
|
26
|
-
/** @see https://vp.teek.top/reference/config/global-config.html#sidebartrigger */
|
|
27
|
-
sidebarTrigger: true,
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 关闭 Teek 主题的首页风格
|
|
31
|
-
* @see https://vp.teek.top/reference/config/global-config.html#teekhome
|
|
32
|
-
*/
|
|
33
|
-
teekHome: false,
|
|
34
|
-
|
|
35
|
-
vitePlugins: {
|
|
36
|
-
/**
|
|
37
|
-
* 关闭 vitepress-plugin-permalink 插件
|
|
38
|
-
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-permalink
|
|
39
|
-
*/
|
|
40
|
-
permalink: false,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 关闭 vitepress-plugin-sidebar-resolve 插件
|
|
44
|
-
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-sidebar-resolve
|
|
45
|
-
*/
|
|
46
|
-
sidebar: false,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 关闭 vitepress-plugin-md-h1 插件
|
|
50
|
-
* @see https://vp.teek.top/guide/plugins.html#vitepress-plugin-md-h1
|
|
51
|
-
*/
|
|
52
|
-
mdH1: false,
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/** @see https://vp.teek.top/reference/article-config.html#articleshare */
|
|
56
|
-
articleShare: {
|
|
57
|
-
enabled: true, // 是否开启文章链接分享功能
|
|
58
|
-
text: "分享此页面", // 分享按钮文本
|
|
59
|
-
copiedText: "链接已复制", // 复制成功文本
|
|
60
|
-
query: false, // 是否包含查询参数
|
|
61
|
-
hash: false, // 是否包含哈希值
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
27
|
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
66
28
|
|
|
67
29
|
/** 默认侧边栏配置 */
|
|
@@ -117,7 +79,11 @@ export function setGenerateSidebar(options?: VitePressSidebarOptions) {
|
|
|
117
79
|
|
|
118
80
|
/** 默认用户配置 */
|
|
119
81
|
const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
120
|
-
|
|
82
|
+
/**
|
|
83
|
+
* 使用默认的 Teek 主题配置
|
|
84
|
+
* 后续会有函数重新设置 Teek 主题配置,并覆盖默认配置
|
|
85
|
+
*/
|
|
86
|
+
extends: defineTeekConfig(defaultTeekConfig),
|
|
121
87
|
|
|
122
88
|
title: "请填写有意义的标题",
|
|
123
89
|
description: "请填写有意义的描述",
|
|
@@ -129,9 +95,7 @@ const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
|
129
95
|
themeConfig: {
|
|
130
96
|
i18nRouting: true,
|
|
131
97
|
|
|
132
|
-
search: {
|
|
133
|
-
provider: "local",
|
|
134
|
-
},
|
|
98
|
+
search: { provider: "local" },
|
|
135
99
|
|
|
136
100
|
// https://vitepress.dev/reference/default-theme-config
|
|
137
101
|
nav: [{ text: "首页", link: "/" }],
|
|
@@ -144,40 +108,20 @@ const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
|
144
108
|
// 自动化侧边栏
|
|
145
109
|
sidebar: setGenerateSidebar(),
|
|
146
110
|
|
|
147
|
-
socialLinks: [
|
|
148
|
-
{
|
|
149
|
-
icon: "github",
|
|
150
|
-
link: "https://github.com/ruan-cat",
|
|
151
|
-
},
|
|
152
|
-
],
|
|
111
|
+
socialLinks: [{ icon: "github", link: "https://github.com/ruan-cat" }],
|
|
153
112
|
},
|
|
154
113
|
|
|
155
114
|
vite: {
|
|
156
|
-
server: {
|
|
157
|
-
open: true,
|
|
158
|
-
port: 8080,
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
plugins: [
|
|
162
|
-
/** @see https://github.com/okineadev/vitepress-plugin-llms */
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
llmstxt(),
|
|
165
|
-
|
|
166
|
-
// @ts-ignore
|
|
167
|
-
GitChangelog({
|
|
168
|
-
// 填写在此处填写您的仓库链接
|
|
169
|
-
repoURL: () => "https://github.com/ruan-cat/monorepo",
|
|
170
|
-
// 最大日志深度为10, 避免获取过多无意义的历史日志
|
|
171
|
-
maxGitLogCount: 10,
|
|
172
|
-
}),
|
|
115
|
+
server: { open: true, port: 8080 },
|
|
173
116
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
117
|
+
/**
|
|
118
|
+
* 插件
|
|
119
|
+
* @description
|
|
120
|
+
* 这里留空 插件在 config/plugins.ts 中配置
|
|
121
|
+
*/
|
|
122
|
+
plugins: [],
|
|
177
123
|
|
|
178
|
-
optimizeDeps: {
|
|
179
|
-
exclude: ["vitepress", "@nolebase/ui"],
|
|
180
|
-
},
|
|
124
|
+
optimizeDeps: { exclude: ["vitepress", "@nolebase/ui"] },
|
|
181
125
|
|
|
182
126
|
ssr: {
|
|
183
127
|
noExternal: [
|
|
@@ -246,12 +190,21 @@ function handleChangeLog(userConfig: UserConfig<DefaultTheme.Config>) {
|
|
|
246
190
|
}
|
|
247
191
|
|
|
248
192
|
/** 设置vitepress主配置 */
|
|
249
|
-
export function setUserConfig(
|
|
193
|
+
export function setUserConfig(
|
|
194
|
+
config?: UserConfig<DefaultTheme.Config>,
|
|
195
|
+
extraConfig?: ExtraConfig,
|
|
196
|
+
): UserConfig<DefaultTheme.Config> {
|
|
250
197
|
/** 最终的用户数据 */
|
|
251
198
|
const resUserConfig = merge({}, cloneDeep(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
252
199
|
|
|
253
200
|
// 增加导航栏
|
|
254
201
|
handleChangeLog(resUserConfig);
|
|
255
202
|
|
|
203
|
+
// 设置插件
|
|
204
|
+
handlePlugins(resUserConfig, extraConfig);
|
|
205
|
+
|
|
206
|
+
// 设置 Teek 主题配置
|
|
207
|
+
handleTeekConfig(resUserConfig, extraConfig);
|
|
208
|
+
|
|
256
209
|
return resUserConfig;
|
|
257
210
|
}
|
package/src/index.ts
ADDED
package/src/theme.ts
CHANGED
|
@@ -55,7 +55,8 @@ function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext) {
|
|
|
55
55
|
/** 默认主题配置 */
|
|
56
56
|
export const defaultTheme = {
|
|
57
57
|
extends: Teek,
|
|
58
|
-
|
|
58
|
+
// 有疑惑 根据和 teek 作者的沟通 这个配置可以不写
|
|
59
|
+
// Layout: Teek.Layout,
|
|
59
60
|
enhanceApp({ app, router, siteData }: EnhanceAppContext) {
|
|
60
61
|
defaultEnhanceAppPreset({ app, router, siteData });
|
|
61
62
|
},
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import llmstxt from "vitepress-plugin-llms";
|
|
2
|
+
import { GitChangelog, type GitChangelogMarkdownSectionOptions } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
3
|
+
|
|
4
|
+
// https://vp.teek.top/guide/quickstart.html#teek-引入
|
|
5
|
+
import { defineTeekConfig } from "vitepress-theme-teek/config";
|
|
6
|
+
|
|
7
|
+
export type LlmstxtSettings = NonNullable<Parameters<typeof llmstxt>[0]>;
|
|
8
|
+
|
|
9
|
+
export type GitChangelogOptions = NonNullable<Parameters<typeof GitChangelog>[0]>;
|
|
10
|
+
|
|
11
|
+
export type TeekConfigOptions = NonNullable<Parameters<typeof defineTeekConfig>[0]>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 额外的配置
|
|
15
|
+
* @description
|
|
16
|
+
* 目前主要用于精细化配置 vitepress 的插件
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtraConfig {
|
|
19
|
+
/**
|
|
20
|
+
* 即 vite 的 plugins
|
|
21
|
+
* @description
|
|
22
|
+
* vitepress 配置的一系列插件
|
|
23
|
+
*/
|
|
24
|
+
plugins?: {
|
|
25
|
+
/**
|
|
26
|
+
* @description 用于配置 vitepress-plugin-llms 插件
|
|
27
|
+
* @see https://github.com/okineadev/vitepress-plugin-llms
|
|
28
|
+
*/
|
|
29
|
+
llmstxt?: LlmstxtSettings | false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description 用于配置 @nolebase/vitepress-plugin-git-changelog 插件
|
|
33
|
+
* @see
|
|
34
|
+
*/
|
|
35
|
+
gitChangelog?: GitChangelogOptions | false;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @description 用于配置 @nolebase/vitepress-plugin-git-changelog-markdown-section 插件
|
|
39
|
+
* @see
|
|
40
|
+
*/
|
|
41
|
+
gitChangelogMarkdownSection?: GitChangelogMarkdownSectionOptions | false;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Teek 主题配置
|
|
46
|
+
* @see https://vp.teek.top/reference/config.html
|
|
47
|
+
*/
|
|
48
|
+
teekConfig?: TeekConfigOptions;
|
|
49
|
+
}
|