@ruan-cat/vitepress-preset-config 0.6.0 → 0.7.1

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/theme.d.mts CHANGED
@@ -1,14 +1,23 @@
1
1
  import * as vue from 'vue';
2
2
  import { EnhanceAppContext } from 'vitepress';
3
3
 
4
- /** 一个回调函数 用来暴露变量 实现注册 */
4
+ /**
5
+ * 一个回调函数 用来暴露变量 实现注册\
6
+ * @deprecated
7
+ */
5
8
  interface EnhanceAppCallBack {
6
9
  ({ app, router, siteData }: EnhanceAppContext): void;
7
10
  }
11
+ /**
12
+ * @deprecated
13
+ */
8
14
  interface DefineRuancatPresetThemeParams {
9
15
  enhanceAppCallBack?: EnhanceAppCallBack;
10
16
  }
11
- /** 定义默认主题预设 */
17
+ /**
18
+ * 定义默认主题预设
19
+ * @deprecated
20
+ */
12
21
  declare function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams): {
13
22
  extends: {
14
23
  Layout: vue.DefineComponent;
@@ -19,5 +28,52 @@ declare function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParam
19
28
  }>;
20
29
  enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
21
30
  };
31
+ /**
32
+ * 默认布局配置
33
+ * @description
34
+ * 有疑惑 经过测试 该写法会导致找不到主题文件
35
+ */
36
+ declare const defaultLayoutConfig: {
37
+ "doc-before": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
38
+ [key: string]: any;
39
+ }>;
40
+ "nav-bar-content-after": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
41
+ [key: string]: any;
42
+ }>;
43
+ "nav-screen-content-after": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
44
+ [key: string]: any;
45
+ }>;
46
+ "layout-top": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
47
+ [key: string]: any;
48
+ }>[];
49
+ };
50
+ /**
51
+ * 默认 enhanceApp 预设
52
+ * @description
53
+ * 有疑惑 经过测试 该写法会导致找不到主题文件
54
+ */
55
+ declare function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext): void;
56
+ /** 默认主题配置 */
57
+ declare const defaultTheme: {
58
+ extends: {
59
+ Layout: vue.DefineComponent;
60
+ enhanceApp: (ctx: EnhanceAppContext) => void;
61
+ };
62
+ Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
63
+ [key: string]: any;
64
+ }>;
65
+ enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
66
+ };
67
+ /**
68
+ * 默认主题配置2
69
+ * @description
70
+ * 从 @sugarat/theme 内学习的配置写法
71
+ */
72
+ declare const defaultTheme2: {
73
+ Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
74
+ [key: string]: any;
75
+ }>;
76
+ enhanceApp(ctx: EnhanceAppContext): void;
77
+ };
22
78
 
23
- export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defineRuancatPresetTheme };
79
+ export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defaultEnhanceAppPreset, defaultLayoutConfig, defaultTheme, defaultTheme2, defineRuancatPresetTheme };
package/dist/theme.mjs CHANGED
@@ -8,13 +8,9 @@ import {
8
8
  InjectionKey,
9
9
  LayoutMode
10
10
  } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
11
- import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
12
11
  import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
13
- import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
14
12
  import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
15
- import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
16
13
  import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
17
- import "@shikijs/vitepress-twoslash/style.css";
18
14
  function defineRuancatPresetTheme(params) {
19
15
  return {
20
16
  extends: DefaultTheme,
@@ -47,6 +43,71 @@ function defineRuancatPresetTheme(params) {
47
43
  }
48
44
  };
49
45
  }
46
+ var defaultLayoutConfig = {
47
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
48
+ "doc-before": () => h(NolebaseBreadcrumbs),
49
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
50
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
51
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
52
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)]
53
+ };
54
+ function defaultEnhanceAppPreset({ app, router, siteData }) {
55
+ app.use(NolebaseGitChangelogPlugin);
56
+ app.use(TwoslashFloatingVue);
57
+ app.provide(InjectionKey, {
58
+ layoutSwitch: {
59
+ defaultMode: LayoutMode["BothWidthAdjustable"],
60
+ pageLayoutMaxWidth: {
61
+ defaultMaxWidth: 85
62
+ },
63
+ contentLayoutMaxWidth: {
64
+ defaultMaxWidth: 95
65
+ }
66
+ }
67
+ });
68
+ }
69
+ var defaultTheme = {
70
+ extends: DefaultTheme,
71
+ Layout: () => {
72
+ return h(DefaultTheme.Layout, null, defaultLayoutConfig);
73
+ },
74
+ enhanceApp({ app, router, siteData }) {
75
+ defaultEnhanceAppPreset({ app, router, siteData });
76
+ }
77
+ };
78
+ var defaultTheme2 = {
79
+ ...DefaultTheme,
80
+ Layout: () => {
81
+ return h(DefaultTheme.Layout, null, {
82
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
83
+ "doc-before": () => h(NolebaseBreadcrumbs),
84
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
85
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
86
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
87
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)]
88
+ });
89
+ },
90
+ enhanceApp(ctx) {
91
+ DefaultTheme.enhanceApp(ctx);
92
+ ctx.app.use(NolebaseGitChangelogPlugin);
93
+ ctx.app.use(TwoslashFloatingVue);
94
+ ctx.app.provide(InjectionKey, {
95
+ layoutSwitch: {
96
+ defaultMode: LayoutMode["BothWidthAdjustable"],
97
+ pageLayoutMaxWidth: {
98
+ defaultMaxWidth: 85
99
+ },
100
+ contentLayoutMaxWidth: {
101
+ defaultMaxWidth: 95
102
+ }
103
+ }
104
+ });
105
+ }
106
+ };
50
107
  export {
108
+ defaultEnhanceAppPreset,
109
+ defaultLayoutConfig,
110
+ defaultTheme,
111
+ defaultTheme2,
51
112
  defineRuancatPresetTheme
52
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vitepress-preset-config",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "用于给大多数的vitepress项目提供一个预设的配置文件。",
5
5
  "homepage": "https://vitepress-preset.ruancat6312.top",
6
6
  "types": "./src/config.mts",
@@ -26,12 +26,16 @@
26
26
  },
27
27
  "peerDependencies": {
28
28
  "vitepress": "^1.6.x",
29
- "vitepress-demo-plugin": "^1"
29
+ "vitepress-demo-plugin": "^1",
30
+ "vue": "^3.5.x"
30
31
  },
31
32
  "peerDependenciesMeta": {
32
33
  "vitepress": {
33
34
  "optional": true
34
35
  },
36
+ "vue": {
37
+ "optional": true
38
+ },
35
39
  "vitepress-demo-plugin": {
36
40
  "optional": false
37
41
  }
@@ -1,6 +1,18 @@
1
- import { defineRuancatPresetTheme } from "../../theme";
1
+ // https://vitepress.dev/guide/custom-theme
2
+ import { h } from "vue";
3
+ import type { Theme, EnhanceAppContext } from "vitepress";
4
+ import DefaultTheme from "vitepress/theme";
5
+ import { defaultLayoutConfig, defaultEnhanceAppPreset } from "@ruan-cat/vitepress-preset-config/theme";
2
6
 
7
+ // 导入全部的主题样式
3
8
  import "@ruan-cat/vitepress-preset-config/theme.css";
4
9
  import "./style.css";
5
-
6
- export default defineRuancatPresetTheme();
10
+ export default {
11
+ extends: DefaultTheme,
12
+ Layout: () => {
13
+ return h(DefaultTheme.Layout, null, defaultLayoutConfig);
14
+ },
15
+ enhanceApp({ app, router, siteData }: EnhanceAppContext) {
16
+ defaultEnhanceAppPreset({ app, router, siteData });
17
+ },
18
+ } satisfies Theme;
package/src/theme.ts CHANGED
@@ -21,27 +21,36 @@ import {
21
21
  type Options,
22
22
  LayoutMode,
23
23
  } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
24
- import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
24
+ // import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
25
25
 
26
26
  import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
27
- import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
27
+ // import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
28
28
 
29
29
  import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
30
- import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
30
+ // import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
31
31
 
32
32
  import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
33
- import "@shikijs/vitepress-twoslash/style.css";
33
+ // import "@shikijs/vitepress-twoslash/style.css";
34
34
 
35
- /** 一个回调函数 用来暴露变量 实现注册 */
35
+ /**
36
+ * 一个回调函数 用来暴露变量 实现注册\
37
+ * @deprecated
38
+ */
36
39
  export interface EnhanceAppCallBack {
37
40
  ({ app, router, siteData }: EnhanceAppContext): void;
38
41
  }
39
42
 
43
+ /**
44
+ * @deprecated
45
+ */
40
46
  export interface DefineRuancatPresetThemeParams {
41
47
  enhanceAppCallBack?: EnhanceAppCallBack;
42
48
  }
43
49
 
44
- /** 定义默认主题预设 */
50
+ /**
51
+ * 定义默认主题预设
52
+ * @deprecated
53
+ */
45
54
  export function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams) {
46
55
  return {
47
56
  extends: DefaultTheme,
@@ -81,3 +90,91 @@ export function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams
81
90
  },
82
91
  } satisfies Theme;
83
92
  }
93
+
94
+ /**
95
+ * 默认布局配置
96
+ * @description
97
+ * 有疑惑 经过测试 该写法会导致找不到主题文件
98
+ */
99
+ export const defaultLayoutConfig = {
100
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
101
+ "doc-before": () => h(NolebaseBreadcrumbs),
102
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
103
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
104
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
105
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)],
106
+ };
107
+
108
+ /**
109
+ * 默认 enhanceApp 预设
110
+ * @description
111
+ * 有疑惑 经过测试 该写法会导致找不到主题文件
112
+ */
113
+ export function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext) {
114
+ app.use(NolebaseGitChangelogPlugin);
115
+ app.use(TwoslashFloatingVue);
116
+ app.provide(InjectionKey, {
117
+ layoutSwitch: {
118
+ defaultMode: LayoutMode["BothWidthAdjustable"],
119
+ pageLayoutMaxWidth: {
120
+ defaultMaxWidth: 85,
121
+ },
122
+ contentLayoutMaxWidth: {
123
+ defaultMaxWidth: 95,
124
+ },
125
+ },
126
+ } as Options);
127
+ }
128
+
129
+ /** 默认主题配置 */
130
+ export const defaultTheme = {
131
+ extends: DefaultTheme,
132
+ Layout: () => {
133
+ return h(DefaultTheme.Layout, null, defaultLayoutConfig);
134
+ },
135
+ enhanceApp({ app, router, siteData }: EnhanceAppContext) {
136
+ defaultEnhanceAppPreset({ app, router, siteData });
137
+ /**
138
+ * 放弃全局注册demo展示组件
139
+ * 在生产环境内使用peer对等依赖
140
+ */
141
+ // app.component("VitepressDemoBox", VitepressDemoBox);
142
+ // app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
143
+ },
144
+ } satisfies Theme;
145
+
146
+ /**
147
+ * 默认主题配置2
148
+ * @description
149
+ * 从 @sugarat/theme 内学习的配置写法
150
+ */
151
+ export const defaultTheme2 = {
152
+ ...DefaultTheme,
153
+ Layout: () => {
154
+ return h(DefaultTheme.Layout, null, {
155
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
156
+ "doc-before": () => h(NolebaseBreadcrumbs),
157
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
158
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
159
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
160
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)],
161
+ });
162
+ },
163
+ enhanceApp(ctx: EnhanceAppContext) {
164
+ DefaultTheme.enhanceApp(ctx);
165
+
166
+ ctx.app.use(NolebaseGitChangelogPlugin);
167
+ ctx.app.use(TwoslashFloatingVue);
168
+ ctx.app.provide(InjectionKey, {
169
+ layoutSwitch: {
170
+ defaultMode: LayoutMode["BothWidthAdjustable"],
171
+ pageLayoutMaxWidth: {
172
+ defaultMaxWidth: 85,
173
+ },
174
+ contentLayoutMaxWidth: {
175
+ defaultMaxWidth: 95,
176
+ },
177
+ },
178
+ } as Options);
179
+ },
180
+ } satisfies Theme;