@ruan-cat/vitepress-preset-config 0.6.0 → 0.7.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/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,33 @@ declare function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParam
19
28
  }>;
20
29
  enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
21
30
  };
31
+ /** 默认布局配置 */
32
+ declare const defaultLayoutConfig: {
33
+ "doc-before": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
34
+ [key: string]: any;
35
+ }>;
36
+ "nav-bar-content-after": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
37
+ [key: string]: any;
38
+ }>;
39
+ "nav-screen-content-after": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
40
+ [key: string]: any;
41
+ }>;
42
+ "layout-top": () => vue.VNode<vue.RendererNode, vue.RendererElement, {
43
+ [key: string]: any;
44
+ }>[];
45
+ };
46
+ /** 默认 enhanceApp 预设 */
47
+ declare function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext): void;
48
+ /** 默认主题配置 */
49
+ declare const defaultTheme: {
50
+ extends: {
51
+ Layout: vue.DefineComponent;
52
+ enhanceApp: (ctx: EnhanceAppContext) => void;
53
+ };
54
+ Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
55
+ [key: string]: any;
56
+ }>;
57
+ enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
58
+ };
22
59
 
23
- export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defineRuancatPresetTheme };
60
+ export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defaultEnhanceAppPreset, defaultLayoutConfig, defaultTheme, 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,41 @@ 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
+ };
50
78
  export {
79
+ defaultEnhanceAppPreset,
80
+ defaultLayoutConfig,
81
+ defaultTheme,
51
82
  defineRuancatPresetTheme
52
83
  };
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.0",
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,47 @@ export function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams
81
90
  },
82
91
  } satisfies Theme;
83
92
  }
93
+
94
+ /** 默认布局配置 */
95
+ export const defaultLayoutConfig = {
96
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
97
+ "doc-before": () => h(NolebaseBreadcrumbs),
98
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
99
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
100
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
101
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)],
102
+ };
103
+
104
+ /** 默认 enhanceApp 预设 */
105
+ export function defaultEnhanceAppPreset({ app, router, siteData }: EnhanceAppContext) {
106
+ app.use(NolebaseGitChangelogPlugin);
107
+ app.use(TwoslashFloatingVue);
108
+ app.provide(InjectionKey, {
109
+ layoutSwitch: {
110
+ defaultMode: LayoutMode["BothWidthAdjustable"],
111
+ pageLayoutMaxWidth: {
112
+ defaultMaxWidth: 85,
113
+ },
114
+ contentLayoutMaxWidth: {
115
+ defaultMaxWidth: 95,
116
+ },
117
+ },
118
+ } as Options);
119
+ }
120
+
121
+ /** 默认主题配置 */
122
+ export const defaultTheme = {
123
+ extends: DefaultTheme,
124
+ Layout: () => {
125
+ return h(DefaultTheme.Layout, null, defaultLayoutConfig);
126
+ },
127
+ enhanceApp({ app, router, siteData }: EnhanceAppContext) {
128
+ defaultEnhanceAppPreset({ app, router, siteData });
129
+ /**
130
+ * 放弃全局注册demo展示组件
131
+ * 在生产环境内使用peer对等依赖
132
+ */
133
+ // app.component("VitepressDemoBox", VitepressDemoBox);
134
+ // app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
135
+ },
136
+ } satisfies Theme;