@ruan-cat/vitepress-preset-config 0.2.0 → 0.3.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.
@@ -0,0 +1,23 @@
1
+ import * as vue from 'vue';
2
+ import { EnhanceAppContext } from 'vitepress';
3
+
4
+ /** 一个回调函数 用来暴露变量 实现注册 */
5
+ interface EnhanceAppCallBack {
6
+ ({ app, router, siteData }: EnhanceAppContext): void;
7
+ }
8
+ interface DefineRuancatPresetThemeParams {
9
+ enhanceAppCallBack?: EnhanceAppCallBack;
10
+ }
11
+ /** 定义默认主题预设 */
12
+ declare function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams): {
13
+ extends: {
14
+ Layout: vue.DefineComponent;
15
+ enhanceApp: (ctx: EnhanceAppContext) => void;
16
+ };
17
+ Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
18
+ [key: string]: any;
19
+ }>;
20
+ enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
21
+ };
22
+
23
+ export { type DefineRuancatPresetThemeParams, type EnhanceAppCallBack, defineRuancatPresetTheme };
package/dist/theme.mjs ADDED
@@ -0,0 +1,56 @@
1
+ // src/theme.ts
2
+ import { h } from "vue";
3
+ import DefaultTheme from "vitepress/theme";
4
+ import { VitepressDemoBox, VitepressDemoPlaceholder } from "vitepress-demo-plugin";
5
+ import "vitepress-demo-plugin/dist/index.css";
6
+ import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
7
+ import {
8
+ NolebaseEnhancedReadabilitiesMenu,
9
+ NolebaseEnhancedReadabilitiesScreenMenu,
10
+ InjectionKey,
11
+ LayoutMode
12
+ } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
13
+ import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
14
+ import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
15
+ import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
16
+ import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
17
+ import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
18
+ import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
19
+ import "@shikijs/vitepress-twoslash/style.css";
20
+ function defineRuancatPresetTheme(params) {
21
+ return {
22
+ extends: DefaultTheme,
23
+ Layout: () => {
24
+ return h(DefaultTheme.Layout, null, {
25
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
26
+ "doc-before": () => h(NolebaseBreadcrumbs),
27
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
28
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
29
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
30
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)]
31
+ });
32
+ },
33
+ enhanceApp({ app, router, siteData }) {
34
+ var _a;
35
+ app.use(NolebaseGitChangelogPlugin);
36
+ app.use(TwoslashFloatingVue);
37
+ app.provide(InjectionKey, {
38
+ layoutSwitch: {
39
+ defaultMode: LayoutMode["BothWidthAdjustable"],
40
+ pageLayoutMaxWidth: {
41
+ defaultMaxWidth: 85
42
+ },
43
+ contentLayoutMaxWidth: {
44
+ defaultMaxWidth: 95
45
+ }
46
+ }
47
+ });
48
+ app.component("VitepressDemoBox", VitepressDemoBox);
49
+ app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
50
+ (_a = params == null ? void 0 : params.enhanceAppCallBack) == null ? void 0 : _a.call(params, { app, router, siteData });
51
+ }
52
+ };
53
+ }
54
+ export {
55
+ defineRuancatPresetTheme
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vitepress-preset-config",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "用于给大多数的vitepress项目提供一个预设的配置文件。",
5
5
  "homepage": "https://vitepress-preset.ruancat6312.top",
6
6
  "types": "./src/config.mts",
@@ -46,8 +46,8 @@
46
46
  "types": "./src/config.mts"
47
47
  },
48
48
  "./theme": {
49
- "import": "./dist/theme/index.mjs",
50
- "types": "./src/.vitepress/theme/index.ts"
49
+ "import": "./dist/theme.mjs",
50
+ "types": "./src/theme.ts"
51
51
  }
52
52
  },
53
53
  "keywords": [
@@ -1,70 +1,5 @@
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 "./style.css";
6
-
7
- import { VitepressDemoBox, VitepressDemoPlaceholder } from "vitepress-demo-plugin";
8
- import "vitepress-demo-plugin/dist/index.css";
9
-
10
- import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
11
-
12
- import {
13
- NolebaseEnhancedReadabilitiesMenu,
14
- NolebaseEnhancedReadabilitiesScreenMenu,
15
-
16
- // https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/#如何在-vitepress-中进行配置
17
- InjectionKey,
18
- type Options,
19
- LayoutMode,
20
- } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
21
- import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
22
-
23
- import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
24
- import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
25
-
26
- import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
27
- import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
28
-
29
- import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
30
- import "@shikijs/vitepress-twoslash/style.css";
1
+ import { defineRuancatPresetTheme } from "../../theme";
31
2
 
32
- const theme = {
33
- extends: DefaultTheme,
34
- Layout: () => {
35
- return h(DefaultTheme.Layout, null, {
36
- // https://vitepress.dev/guide/extending-default-theme#layout-slots
37
-
38
- "doc-before": () => h(NolebaseBreadcrumbs),
39
-
40
- "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
41
- // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
42
- "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
43
-
44
- "layout-top": () => [h(NolebaseHighlightTargetedHeading)],
45
- });
46
- },
47
- enhanceApp({ app, router, siteData }: EnhanceAppContext) {
48
- app.use(NolebaseGitChangelogPlugin);
49
-
50
- app.use(TwoslashFloatingVue);
51
-
52
- app.provide(InjectionKey, {
53
- layoutSwitch: {
54
- defaultMode: LayoutMode["BothWidthAdjustable"],
55
- pageLayoutMaxWidth: {
56
- defaultMaxWidth: 85,
57
- },
58
- contentLayoutMaxWidth: {
59
- defaultMaxWidth: 95,
60
- },
61
- },
62
- } as Options);
63
-
64
- // 全局注册demo展示组件
65
- app.component("VitepressDemoBox", VitepressDemoBox);
66
- app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
67
- },
68
- } satisfies Theme;
3
+ import "./style.css";
69
4
 
70
- export default theme;
5
+ export default defineRuancatPresetTheme();
package/src/theme.ts ADDED
@@ -0,0 +1,75 @@
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
+
6
+ import { VitepressDemoBox, VitepressDemoPlaceholder } from "vitepress-demo-plugin";
7
+ import "vitepress-demo-plugin/dist/index.css";
8
+
9
+ import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
10
+
11
+ import {
12
+ NolebaseEnhancedReadabilitiesMenu,
13
+ NolebaseEnhancedReadabilitiesScreenMenu,
14
+
15
+ // https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/#如何在-vitepress-中进行配置
16
+ InjectionKey,
17
+ type Options,
18
+ LayoutMode,
19
+ } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
20
+ import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
21
+
22
+ import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
23
+ import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
24
+
25
+ import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
26
+ import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
27
+
28
+ import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
29
+ import "@shikijs/vitepress-twoslash/style.css";
30
+
31
+ /** 一个回调函数 用来暴露变量 实现注册 */
32
+ export interface EnhanceAppCallBack {
33
+ ({ app, router, siteData }: EnhanceAppContext): void;
34
+ }
35
+
36
+ export interface DefineRuancatPresetThemeParams {
37
+ enhanceAppCallBack?: EnhanceAppCallBack;
38
+ }
39
+
40
+ /** 定义默认主题预设 */
41
+ export function defineRuancatPresetTheme(params?: DefineRuancatPresetThemeParams) {
42
+ return {
43
+ extends: DefaultTheme,
44
+ Layout: () => {
45
+ return h(DefaultTheme.Layout, null, {
46
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
47
+ "doc-before": () => h(NolebaseBreadcrumbs),
48
+ "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
49
+ // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
50
+ "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
51
+ "layout-top": () => [h(NolebaseHighlightTargetedHeading)],
52
+ });
53
+ },
54
+ enhanceApp({ app, router, siteData }: EnhanceAppContext) {
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
+ } as Options);
68
+ // 全局注册demo展示组件
69
+ app.component("VitepressDemoBox", VitepressDemoBox);
70
+ app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
71
+
72
+ params?.enhanceAppCallBack?.({ app, router, siteData });
73
+ },
74
+ } satisfies Theme;
75
+ }
@@ -1,63 +0,0 @@
1
- /* src/.vitepress/theme/style.css */
2
- :root {
3
- --vp-c-default-1: var(--vp-c-gray-1);
4
- --vp-c-default-2: var(--vp-c-gray-2);
5
- --vp-c-default-3: var(--vp-c-gray-3);
6
- --vp-c-default-soft: var(--vp-c-gray-soft);
7
- --vp-c-brand-1: var(--vp-c-indigo-1);
8
- --vp-c-brand-2: var(--vp-c-indigo-2);
9
- --vp-c-brand-3: var(--vp-c-indigo-3);
10
- --vp-c-brand-soft: var(--vp-c-indigo-soft);
11
- --vp-c-tip-1: var(--vp-c-brand-1);
12
- --vp-c-tip-2: var(--vp-c-brand-2);
13
- --vp-c-tip-3: var(--vp-c-brand-3);
14
- --vp-c-tip-soft: var(--vp-c-brand-soft);
15
- --vp-c-warning-1: var(--vp-c-yellow-1);
16
- --vp-c-warning-2: var(--vp-c-yellow-2);
17
- --vp-c-warning-3: var(--vp-c-yellow-3);
18
- --vp-c-warning-soft: var(--vp-c-yellow-soft);
19
- --vp-c-danger-1: var(--vp-c-red-1);
20
- --vp-c-danger-2: var(--vp-c-red-2);
21
- --vp-c-danger-3: var(--vp-c-red-3);
22
- --vp-c-danger-soft: var(--vp-c-red-soft);
23
- }
24
- :root {
25
- --vp-button-brand-border: transparent;
26
- --vp-button-brand-text: var(--vp-c-white);
27
- --vp-button-brand-bg: var(--vp-c-brand-3);
28
- --vp-button-brand-hover-border: transparent;
29
- --vp-button-brand-hover-text: var(--vp-c-white);
30
- --vp-button-brand-hover-bg: var(--vp-c-brand-2);
31
- --vp-button-brand-active-border: transparent;
32
- --vp-button-brand-active-text: var(--vp-c-white);
33
- --vp-button-brand-active-bg: var(--vp-c-brand-1);
34
- }
35
- :root {
36
- --vp-home-hero-name-color: transparent;
37
- --vp-home-hero-name-background: -webkit-linear-gradient(120deg, #bd34fe 30%, #41d1ff);
38
- --vp-home-hero-image-background-image:
39
- linear-gradient(
40
- -45deg,
41
- #bd34fe 50%,
42
- #47caff 50%);
43
- --vp-home-hero-image-filter: blur(44px);
44
- }
45
- @media (min-width: 640px) {
46
- :root {
47
- --vp-home-hero-image-filter: blur(56px);
48
- }
49
- }
50
- @media (min-width: 960px) {
51
- :root {
52
- --vp-home-hero-image-filter: blur(68px);
53
- }
54
- }
55
- :root {
56
- --vp-custom-block-tip-border: transparent;
57
- --vp-custom-block-tip-text: var(--vp-c-text-1);
58
- --vp-custom-block-tip-bg: var(--vp-c-brand-soft);
59
- --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
60
- }
61
- .DocSearch {
62
- --docsearch-primary-color: var(--vp-c-brand-1) !important;
63
- }
@@ -1,15 +0,0 @@
1
- import * as vue from 'vue';
2
- import { EnhanceAppContext } from 'vitepress';
3
-
4
- declare const theme: {
5
- extends: {
6
- Layout: vue.DefineComponent;
7
- enhanceApp: (ctx: EnhanceAppContext) => void;
8
- };
9
- Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
10
- [key: string]: any;
11
- }>;
12
- enhanceApp({ app, router, siteData }: EnhanceAppContext): void;
13
- };
14
-
15
- export { theme as default };
@@ -1,53 +0,0 @@
1
- // src/.vitepress/theme/index.ts
2
- import { h } from "vue";
3
- import DefaultTheme from "vitepress/theme";
4
- import { VitepressDemoBox, VitepressDemoPlaceholder } from "vitepress-demo-plugin";
5
- import "vitepress-demo-plugin/dist/index.css";
6
- import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
7
- import {
8
- NolebaseEnhancedReadabilitiesMenu,
9
- NolebaseEnhancedReadabilitiesScreenMenu,
10
- InjectionKey,
11
- LayoutMode
12
- } from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
13
- import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
14
- import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
15
- import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
16
- import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
17
- import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
18
- import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
19
- import "@shikijs/vitepress-twoslash/style.css";
20
- var theme = {
21
- extends: DefaultTheme,
22
- Layout: () => {
23
- return h(DefaultTheme.Layout, null, {
24
- // https://vitepress.dev/guide/extending-default-theme#layout-slots
25
- "doc-before": () => h(NolebaseBreadcrumbs),
26
- "nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
27
- // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
28
- "nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
29
- "layout-top": () => [h(NolebaseHighlightTargetedHeading)]
30
- });
31
- },
32
- enhanceApp({ app, router, siteData }) {
33
- app.use(NolebaseGitChangelogPlugin);
34
- app.use(TwoslashFloatingVue);
35
- app.provide(InjectionKey, {
36
- layoutSwitch: {
37
- defaultMode: LayoutMode["BothWidthAdjustable"],
38
- pageLayoutMaxWidth: {
39
- defaultMaxWidth: 85
40
- },
41
- contentLayoutMaxWidth: {
42
- defaultMaxWidth: 95
43
- }
44
- }
45
- });
46
- app.component("VitepressDemoBox", VitepressDemoBox);
47
- app.component("VitepressDemoPlaceholder", VitepressDemoPlaceholder);
48
- }
49
- };
50
- var index_default = theme;
51
- export {
52
- index_default as default
53
- };