@ruan-cat/vitepress-preset-config 0.0.3 → 0.1.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 +13 -0
- package/dist/theme/index.d.mts +3 -3
- package/dist/theme/index.mjs +3 -0
- package/package.json +4 -5
- package/src/.vitepress/theme/index.ts +7 -3
- package/src/config.mts +20 -0
package/dist/config.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
|
6
6
|
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
7
7
|
import consola from "consola";
|
|
8
8
|
import { addChangelog2doc, hasChangelogMd } from "@ruan-cat/utils/node-esm";
|
|
9
|
+
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
9
10
|
var defaultSidebarOptions = {
|
|
10
11
|
// documentRootPath: "src",
|
|
11
12
|
// 侧边栏需要折叠
|
|
@@ -96,6 +97,18 @@ var defaultUserConfig = {
|
|
|
96
97
|
markdown: {
|
|
97
98
|
config(md) {
|
|
98
99
|
md.use(vitepressDemoPlugin);
|
|
100
|
+
},
|
|
101
|
+
codeTransformers: [
|
|
102
|
+
// @ts-ignore FIXME: 这里出现奇怪的类型报错 屏蔽了
|
|
103
|
+
transformerTwoslash()
|
|
104
|
+
],
|
|
105
|
+
// languages: ["js", "jsx", "ts", "tsx"],
|
|
106
|
+
container: {
|
|
107
|
+
tipLabel: "\u63D0\u793A",
|
|
108
|
+
warningLabel: "\u8B66\u544A",
|
|
109
|
+
dangerLabel: "\u5371\u9669",
|
|
110
|
+
infoLabel: "\u4FE1\u606F",
|
|
111
|
+
detailsLabel: "\u8BE6\u60C5"
|
|
99
112
|
}
|
|
100
113
|
}
|
|
101
114
|
};
|
package/dist/theme/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as vitepress from 'vitepress';
|
|
2
1
|
import * as vue from 'vue';
|
|
2
|
+
import { EnhanceAppContext } from 'vitepress';
|
|
3
3
|
|
|
4
4
|
declare const theme: {
|
|
5
5
|
extends: {
|
|
6
6
|
Layout: vue.DefineComponent;
|
|
7
|
-
enhanceApp: (ctx:
|
|
7
|
+
enhanceApp: (ctx: EnhanceAppContext) => void;
|
|
8
8
|
};
|
|
9
9
|
Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}>;
|
|
12
|
-
enhanceApp({ app, router, siteData }:
|
|
12
|
+
enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { theme as default };
|
package/dist/theme/index.mjs
CHANGED
|
@@ -13,6 +13,8 @@ import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-hig
|
|
|
13
13
|
import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
|
|
14
14
|
import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
|
|
15
15
|
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
16
|
+
import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
17
|
+
import "@shikijs/vitepress-twoslash/style.css";
|
|
16
18
|
var theme = {
|
|
17
19
|
extends: DefaultTheme,
|
|
18
20
|
Layout: () => {
|
|
@@ -27,6 +29,7 @@ var theme = {
|
|
|
27
29
|
},
|
|
28
30
|
enhanceApp({ app, router, siteData }) {
|
|
29
31
|
app.use(NolebaseGitChangelogPlugin);
|
|
32
|
+
app.use(TwoslashFloatingVue);
|
|
30
33
|
app.provide(InjectionKey, {
|
|
31
34
|
layoutSwitch: {
|
|
32
35
|
defaultMode: LayoutMode["BothWidthAdjustable"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/vitepress-preset-config",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "用于给大多数的vitepress项目提供一个预设的配置文件。",
|
|
5
5
|
"homepage": "https://vitepress-preset.ruancat6312.top",
|
|
6
6
|
"types": "./src/config.mts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@nolebase/vitepress-plugin-enhanced-readabilities": "^2.15.1",
|
|
11
11
|
"@nolebase/vitepress-plugin-git-changelog": "^2.15.1",
|
|
12
12
|
"@nolebase/vitepress-plugin-highlight-targeted-heading": "^2.15.1",
|
|
13
|
+
"@shikijs/vitepress-twoslash": "^3.2.1",
|
|
13
14
|
"consola": "^3.4.0",
|
|
14
15
|
"js-yaml": "^4.1.0",
|
|
15
16
|
"lodash-es": "^4.17.21",
|
|
@@ -81,9 +82,7 @@
|
|
|
81
82
|
],
|
|
82
83
|
"scripts": {
|
|
83
84
|
"docs:dev": "vitepress dev src --port 8080",
|
|
84
|
-
"
|
|
85
|
-
"build
|
|
86
|
-
"do-build": "tsup",
|
|
87
|
-
"build": "turbo do-build"
|
|
85
|
+
"build:docs": "vitepress build src",
|
|
86
|
+
"build": "tsup"
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://vitepress.dev/guide/custom-theme
|
|
2
2
|
import { h } from "vue";
|
|
3
|
-
import type { Theme } from "vitepress";
|
|
3
|
+
import type { Theme, EnhanceAppContext } from "vitepress";
|
|
4
4
|
import DefaultTheme from "vitepress/theme";
|
|
5
5
|
import "./style.css";
|
|
6
6
|
|
|
@@ -23,6 +23,9 @@ import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
|
|
|
23
23
|
import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
|
|
24
24
|
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
25
25
|
|
|
26
|
+
import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
27
|
+
import "@shikijs/vitepress-twoslash/style.css";
|
|
28
|
+
|
|
26
29
|
const theme = {
|
|
27
30
|
extends: DefaultTheme,
|
|
28
31
|
Layout: () => {
|
|
@@ -38,10 +41,11 @@ const theme = {
|
|
|
38
41
|
"layout-top": () => [h(NolebaseHighlightTargetedHeading)],
|
|
39
42
|
});
|
|
40
43
|
},
|
|
41
|
-
enhanceApp({ app, router, siteData }) {
|
|
42
|
-
// ...
|
|
44
|
+
enhanceApp({ app, router, siteData }: EnhanceAppContext) {
|
|
43
45
|
app.use(NolebaseGitChangelogPlugin);
|
|
44
46
|
|
|
47
|
+
app.use(TwoslashFloatingVue);
|
|
48
|
+
|
|
45
49
|
app.provide(InjectionKey, {
|
|
46
50
|
layoutSwitch: {
|
|
47
51
|
defaultMode: LayoutMode["BothWidthAdjustable"],
|
package/src/config.mts
CHANGED
|
@@ -12,6 +12,8 @@ import consola from "consola";
|
|
|
12
12
|
import { addChangelog2doc, hasChangelogMd } from "@ruan-cat/utils/node-esm";
|
|
13
13
|
export { addChangelog2doc };
|
|
14
14
|
|
|
15
|
+
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
16
|
+
|
|
15
17
|
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
16
18
|
|
|
17
19
|
/** 默认侧边栏配置 */
|
|
@@ -140,6 +142,20 @@ const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
|
140
142
|
config(md) {
|
|
141
143
|
md.use(vitepressDemoPlugin);
|
|
142
144
|
},
|
|
145
|
+
|
|
146
|
+
codeTransformers: [
|
|
147
|
+
// @ts-ignore FIXME: 这里出现奇怪的类型报错 屏蔽了
|
|
148
|
+
transformerTwoslash(),
|
|
149
|
+
],
|
|
150
|
+
// languages: ["js", "jsx", "ts", "tsx"],
|
|
151
|
+
|
|
152
|
+
container: {
|
|
153
|
+
tipLabel: "提示",
|
|
154
|
+
warningLabel: "警告",
|
|
155
|
+
dangerLabel: "危险",
|
|
156
|
+
infoLabel: "信息",
|
|
157
|
+
detailsLabel: "详情",
|
|
158
|
+
},
|
|
143
159
|
},
|
|
144
160
|
};
|
|
145
161
|
|
|
@@ -167,6 +183,10 @@ function handleChangeLog(userConfig: UserConfig<DefaultTheme.Config>) {
|
|
|
167
183
|
nav.push({ text: "更新日志", link: "/CHANGELOG.md" });
|
|
168
184
|
}
|
|
169
185
|
|
|
186
|
+
// function addTwoslashPlugin(userConfig: UserConfig<DefaultTheme.Config>) {
|
|
187
|
+
// userConfig.markdown?.codeTransformers?.push(transformerTwoslash());
|
|
188
|
+
// }
|
|
189
|
+
|
|
170
190
|
/** 设置vitepress主配置 */
|
|
171
191
|
export function setUserConfig(config?: UserConfig<DefaultTheme.Config>) {
|
|
172
192
|
/** 最终的用户数据 */
|