@ruan-cat/vitepress-preset-config 2.0.0 → 2.2.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.mjs +27 -4
- package/dist/theme.mjs +2 -0
- package/package.json +1 -1
- package/src/config/teek.ts +17 -1
- package/src/config.mts +4 -1
- package/src/theme.ts +6 -1
package/dist/config.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { merge as merge2, isUndefined, cloneDeep as cloneDeep2 } from "lodash-es
|
|
|
6
6
|
import consola from "consola";
|
|
7
7
|
import { addChangelog2doc, hasChangelogMd, copyReadmeMd } from "@ruan-cat/utils/node-esm";
|
|
8
8
|
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
9
|
+
import { copyOrDownloadAsMarkdownButtons } from "vitepress-plugin-llms";
|
|
9
10
|
|
|
10
11
|
// src/config/plugins.ts
|
|
11
12
|
import vitepressPluginLlmstxt from "vitepress-plugin-llms";
|
|
@@ -22,12 +23,12 @@ var defaultGitChangelogOptions = {
|
|
|
22
23
|
function getPlugins(extraConfig) {
|
|
23
24
|
const plugins = [];
|
|
24
25
|
const {
|
|
25
|
-
llmstxt,
|
|
26
|
+
llmstxt: llmstxt2,
|
|
26
27
|
gitChangelog = defaultGitChangelogOptions,
|
|
27
28
|
gitChangelogMarkdownSection
|
|
28
29
|
} = (extraConfig == null ? void 0 : extraConfig.plugins) || {};
|
|
29
|
-
if (!isFalse(
|
|
30
|
-
plugins.push(vitepressPluginLlmstxt(
|
|
30
|
+
if (!isFalse(llmstxt2)) {
|
|
31
|
+
plugins.push(vitepressPluginLlmstxt(llmstxt2));
|
|
31
32
|
}
|
|
32
33
|
if (!isFalse(gitChangelog)) {
|
|
33
34
|
plugins.push(GitChangelog(gitChangelog));
|
|
@@ -45,13 +46,34 @@ function handlePlugins(userConfig, extraConfig) {
|
|
|
45
46
|
import { defineTeekConfig } from "vitepress-theme-teek/config";
|
|
46
47
|
import { merge, cloneDeep } from "lodash-es";
|
|
47
48
|
var defaultTeekConfig = {
|
|
48
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* 启用侧边栏展开/折叠触发器
|
|
51
|
+
* @see https://vp.teek.top/reference/config/global-config.html#sidebartrigger
|
|
52
|
+
*/
|
|
49
53
|
sidebarTrigger: true,
|
|
50
54
|
/**
|
|
51
55
|
* 关闭 Teek 主题的首页风格
|
|
52
56
|
* @see https://vp.teek.top/reference/config/global-config.html#teekhome
|
|
53
57
|
*/
|
|
54
58
|
teekHome: false,
|
|
59
|
+
/**
|
|
60
|
+
* 启用新版代码块
|
|
61
|
+
* @see https://vp.teek.top/reference/config/global-config.html#codeblock
|
|
62
|
+
*/
|
|
63
|
+
codeBlock: {
|
|
64
|
+
enabled: true,
|
|
65
|
+
// 是否启用新版代码块
|
|
66
|
+
collapseHeight: 700,
|
|
67
|
+
// 超出高度后自动折叠,设置 true 则默认折叠,false 则默认不折叠
|
|
68
|
+
overlay: true,
|
|
69
|
+
// 代码块底部是否显示展开/折叠遮罩层
|
|
70
|
+
overlayHeight: 400,
|
|
71
|
+
// 当出现遮罩层时,指定代码块显示高度,当 overlay 为 true 时生效
|
|
72
|
+
langTextTransform: "lowercase",
|
|
73
|
+
// 语言文本显示样式,为 text-transform 的值:none, capitalize, lowercase, uppercase
|
|
74
|
+
copiedDone: (TkMessage) => TkMessage.success("\u590D\u5236\u6210\u529F\uFF01")
|
|
75
|
+
// 复制代码完成后的回调
|
|
76
|
+
},
|
|
55
77
|
vitePlugins: {
|
|
56
78
|
/**
|
|
57
79
|
* 关闭 vitepress-plugin-permalink 插件
|
|
@@ -166,6 +188,7 @@ var defaultUserConfig = {
|
|
|
166
188
|
config(md) {
|
|
167
189
|
md.use(vitepressDemoPlugin);
|
|
168
190
|
MermaidPlugin(md);
|
|
191
|
+
md.use(copyOrDownloadAsMarkdownButtons);
|
|
169
192
|
},
|
|
170
193
|
codeTransformers: [
|
|
171
194
|
// @ts-ignore FIXME: 这里出现奇怪的类型报错 屏蔽了
|
package/dist/theme.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-chang
|
|
|
3
3
|
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
4
4
|
import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
5
5
|
import "@shikijs/vitepress-twoslash/style.css";
|
|
6
|
+
import CopyOrDownloadAsMarkdownButtons from "vitepress-plugin-llms/vitepress-components/CopyOrDownloadAsMarkdownButtons.vue";
|
|
6
7
|
import Teek from "vitepress-theme-teek";
|
|
7
8
|
import "vitepress-theme-teek/index.css";
|
|
8
9
|
import { Mermaid } from "@leelaa/vitepress-plugin-extended";
|
|
@@ -10,6 +11,7 @@ function defaultEnhanceAppPreset({ app, router, siteData }) {
|
|
|
10
11
|
app.use(NolebaseGitChangelogPlugin);
|
|
11
12
|
app.use(TwoslashFloatingVue);
|
|
12
13
|
app.component("Mermaid", Mermaid);
|
|
14
|
+
app.component("CopyOrDownloadAsMarkdownButtons", CopyOrDownloadAsMarkdownButtons);
|
|
13
15
|
}
|
|
14
16
|
var defaultTheme = {
|
|
15
17
|
extends: Teek,
|
package/package.json
CHANGED
package/src/config/teek.ts
CHANGED
|
@@ -9,7 +9,10 @@ import type { TeekConfigOptions, ExtraConfig } from "../types";
|
|
|
9
9
|
* @see https://vp.teek.top/reference/config.html
|
|
10
10
|
*/
|
|
11
11
|
export const defaultTeekConfig: TeekConfigOptions = {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* 启用侧边栏展开/折叠触发器
|
|
14
|
+
* @see https://vp.teek.top/reference/config/global-config.html#sidebartrigger
|
|
15
|
+
*/
|
|
13
16
|
sidebarTrigger: true,
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -18,6 +21,19 @@ export const defaultTeekConfig: TeekConfigOptions = {
|
|
|
18
21
|
*/
|
|
19
22
|
teekHome: false,
|
|
20
23
|
|
|
24
|
+
/**
|
|
25
|
+
* 启用新版代码块
|
|
26
|
+
* @see https://vp.teek.top/reference/config/global-config.html#codeblock
|
|
27
|
+
*/
|
|
28
|
+
codeBlock: {
|
|
29
|
+
enabled: true, // 是否启用新版代码块
|
|
30
|
+
collapseHeight: 700, // 超出高度后自动折叠,设置 true 则默认折叠,false 则默认不折叠
|
|
31
|
+
overlay: true, // 代码块底部是否显示展开/折叠遮罩层
|
|
32
|
+
overlayHeight: 400, // 当出现遮罩层时,指定代码块显示高度,当 overlay 为 true 时生效
|
|
33
|
+
langTextTransform: "lowercase", // 语言文本显示样式,为 text-transform 的值:none, capitalize, lowercase, uppercase
|
|
34
|
+
copiedDone: (TkMessage) => TkMessage.success("复制成功!"), // 复制代码完成后的回调
|
|
35
|
+
},
|
|
36
|
+
|
|
21
37
|
vitePlugins: {
|
|
22
38
|
/**
|
|
23
39
|
* 关闭 vitepress-plugin-permalink 插件
|
package/src/config.mts
CHANGED
|
@@ -14,7 +14,7 @@ export { addChangelog2doc, copyReadmeMd };
|
|
|
14
14
|
|
|
15
15
|
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
16
16
|
|
|
17
|
-
import llmstxt from "vitepress-plugin-llms";
|
|
17
|
+
import llmstxt, { copyOrDownloadAsMarkdownButtons } from "vitepress-plugin-llms";
|
|
18
18
|
|
|
19
19
|
import { defaultTeekConfig, handleTeekConfig, handlePlugins } from "./config/index.ts";
|
|
20
20
|
|
|
@@ -137,6 +137,9 @@ const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
|
137
137
|
|
|
138
138
|
// @ts-ignore
|
|
139
139
|
MermaidPlugin(md);
|
|
140
|
+
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
md.use(copyOrDownloadAsMarkdownButtons);
|
|
140
143
|
},
|
|
141
144
|
|
|
142
145
|
codeTransformers: [
|
package/src/theme.ts
CHANGED
|
@@ -13,12 +13,16 @@ import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
|
13
13
|
import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
14
14
|
import "@shikijs/vitepress-twoslash/style.css";
|
|
15
15
|
|
|
16
|
+
/** @see https://github.com/okineadev/vitepress-plugin-llms/blob/main/README.md */
|
|
17
|
+
// @ts-ignore FIXME: 该组件直接使用时没有故障的 但是tsup打包有故障 故忽略类型报错
|
|
18
|
+
import CopyOrDownloadAsMarkdownButtons from "vitepress-plugin-llms/vitepress-components/CopyOrDownloadAsMarkdownButtons.vue";
|
|
19
|
+
|
|
16
20
|
// https://vp.teek.top/guide/quickstart.html#teek-引入
|
|
17
21
|
import Teek from "vitepress-theme-teek";
|
|
18
22
|
import "vitepress-theme-teek/index.css";
|
|
19
23
|
|
|
20
24
|
/** @see https://vitepress-ext.leelaa.cn/Mermaid.html#全局引入 */
|
|
21
|
-
// @ts-ignore
|
|
25
|
+
// @ts-ignore FIXME: 忽略类型导出的bug 避免tsup打包失败
|
|
22
26
|
import { Mermaid } from "@leelaa/vitepress-plugin-extended";
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -44,6 +48,7 @@ function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext) {
|
|
|
44
48
|
app.use(NolebaseGitChangelogPlugin);
|
|
45
49
|
app.use(TwoslashFloatingVue);
|
|
46
50
|
app.component("Mermaid", Mermaid);
|
|
51
|
+
app.component("CopyOrDownloadAsMarkdownButtons", CopyOrDownloadAsMarkdownButtons);
|
|
47
52
|
/**
|
|
48
53
|
* 放弃全局注册demo展示组件
|
|
49
54
|
* 在生产环境内使用peer对等依赖
|