@ruan-cat/vitepress-preset-config 0.0.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/config.d.mts +16 -0
- package/dist/config.mjs +114 -0
- package/dist/theme/index.css +63 -0
- package/dist/theme/index.d.mts +15 -0
- package/dist/theme/index.mjs +46 -0
- package/package.json +88 -0
- package/src/.vitepress/config.mts +21 -0
- package/src/.vitepress/theme/index.ts +59 -0
- package/src/.vitepress/theme/style.css +130 -0
- package/src/config.mts +157 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as vitepress_sidebar_types from 'vitepress-sidebar/types';
|
|
2
|
+
import { UserConfig, DefaultTheme } from 'vitepress';
|
|
3
|
+
export { defineConfig } from 'vitepress';
|
|
4
|
+
import { generateSidebar } from 'vitepress-sidebar';
|
|
5
|
+
export { addChangelog2doc } from '@ruan-cat/utils/node-esm';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 设置自动生成侧边栏的配置
|
|
9
|
+
* @see https://vitepress-sidebar.cdget.com/zhHans/guide/options
|
|
10
|
+
*/
|
|
11
|
+
declare function setGenerateSidebar(options?: VitePressSidebarOptions): vitepress_sidebar_types.Sidebar;
|
|
12
|
+
/** 设置vitepress主配置 */
|
|
13
|
+
declare function setUserConfig(config?: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
|
14
|
+
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
15
|
+
|
|
16
|
+
export { setGenerateSidebar, setUserConfig };
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/config.mts
|
|
2
|
+
import { defineConfig } from "vitepress";
|
|
3
|
+
import { generateSidebar } from "vitepress-sidebar";
|
|
4
|
+
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
5
|
+
import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
6
|
+
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
7
|
+
import { addChangelog2doc } from "@ruan-cat/utils/node-esm";
|
|
8
|
+
var defaultSidebarOptions = {
|
|
9
|
+
// documentRootPath: "src",
|
|
10
|
+
// 侧边栏需要折叠
|
|
11
|
+
collapsed: true,
|
|
12
|
+
// 不需要配置折叠嵌套深度
|
|
13
|
+
// collapseDepth: 4,
|
|
14
|
+
// 不需要索引首页 首页直接在标题内找到即可
|
|
15
|
+
// includeRootIndexFile: true,
|
|
16
|
+
// 不需要索引文件夹
|
|
17
|
+
// includeFolderIndexFile: true,
|
|
18
|
+
// 用文件的 h1 标题作为侧边栏标题
|
|
19
|
+
useTitleFromFileHeading: true,
|
|
20
|
+
// 用index文件的标题作为折叠栏的标题
|
|
21
|
+
useFolderTitleFromIndexFile: true,
|
|
22
|
+
// 折叠栏链接到index文件
|
|
23
|
+
useFolderLinkFromIndexFile: true,
|
|
24
|
+
// 用order字段做菜单排序
|
|
25
|
+
sortMenusByFrontmatterOrder: true,
|
|
26
|
+
// 不使用倒序排序
|
|
27
|
+
// sortMenusOrderByDescending: true,
|
|
28
|
+
sortMenusByName: false,
|
|
29
|
+
useFolderLinkFromSameNameSubFile: true,
|
|
30
|
+
debugPrint: true
|
|
31
|
+
};
|
|
32
|
+
function getMergeSidebarOptions(options) {
|
|
33
|
+
return merge({}, cloneDeep(defaultSidebarOptions), isUndefined(options) ? {} : options);
|
|
34
|
+
}
|
|
35
|
+
function setGenerateSidebar(options) {
|
|
36
|
+
return generateSidebar(getMergeSidebarOptions(options));
|
|
37
|
+
}
|
|
38
|
+
var defaultUserConfig = {
|
|
39
|
+
title: "10wms\u524D\u7AEF\u7EC4\u6280\u672F\u6587\u6863",
|
|
40
|
+
description: "\u672C\u524D\u7AEF\u9879\u76EE\u5185\u7684\u7EC4\u4EF6\u4F7F\u7528\u3001api\u3001\u7C7B\u578B\u4EE5\u53CA\u4F7F\u7528\u6587\u6863",
|
|
41
|
+
lang: "zh",
|
|
42
|
+
// 暂不需要
|
|
43
|
+
// srcDir: "./src",
|
|
44
|
+
themeConfig: {
|
|
45
|
+
i18nRouting: true,
|
|
46
|
+
search: {
|
|
47
|
+
provider: "local"
|
|
48
|
+
},
|
|
49
|
+
// https://vitepress.dev/reference/default-theme-config
|
|
50
|
+
nav: [
|
|
51
|
+
{ text: "\u9996\u9875", link: "/" },
|
|
52
|
+
{ text: "\u66F4\u65B0\u65E5\u5FD7", link: "/CHANGELOG.md" }
|
|
53
|
+
// TODO: 未来项目结束时,在此补充配置
|
|
54
|
+
// { text: "仓库地址", link: "https://github.com/ruan-cat/vercel-monorepo-test/tree/dev/packages/docs-01-star" },
|
|
55
|
+
],
|
|
56
|
+
outline: {
|
|
57
|
+
label: "\u672C\u9875\u76EE\u5F55",
|
|
58
|
+
level: "deep"
|
|
59
|
+
},
|
|
60
|
+
// 自动化侧边栏
|
|
61
|
+
sidebar: setGenerateSidebar(),
|
|
62
|
+
socialLinks: [
|
|
63
|
+
{
|
|
64
|
+
icon: "github",
|
|
65
|
+
link: "https://github.com/ruan-cat/vercel-monorepo-test/blob/dev/packages/docs-01-star/docs/index.md"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
vite: {
|
|
70
|
+
server: {
|
|
71
|
+
open: true
|
|
72
|
+
},
|
|
73
|
+
plugins: [
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
GitChangelog({
|
|
76
|
+
// 填写在此处填写您的仓库链接
|
|
77
|
+
repoURL: () => "https://github.com/ruan-cat/vercel-monorepo-test"
|
|
78
|
+
}),
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
GitChangelogMarkdownSection()
|
|
81
|
+
],
|
|
82
|
+
optimizeDeps: {
|
|
83
|
+
exclude: [
|
|
84
|
+
"@nolebase/vitepress-plugin-breadcrumbs/client",
|
|
85
|
+
"@nolebase/vitepress-plugin-enhanced-readabilities/client",
|
|
86
|
+
"vitepress",
|
|
87
|
+
"@nolebase/ui"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
ssr: {
|
|
91
|
+
noExternal: [
|
|
92
|
+
// 如果还有别的依赖需要添加的话,并排填写和配置到这里即可
|
|
93
|
+
"@nolebase/vitepress-plugin-breadcrumbs",
|
|
94
|
+
"@nolebase/vitepress-plugin-enhanced-readabilities",
|
|
95
|
+
"@nolebase/ui",
|
|
96
|
+
"@nolebase/vitepress-plugin-highlight-targeted-heading"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
markdown: {
|
|
101
|
+
config(md) {
|
|
102
|
+
md.use(vitepressDemoPlugin);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function setUserConfig(config) {
|
|
107
|
+
return merge({}, cloneDeep(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
addChangelog2doc,
|
|
111
|
+
defineConfig,
|
|
112
|
+
setGenerateSidebar,
|
|
113
|
+
setUserConfig
|
|
114
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as vitepress from 'vitepress';
|
|
2
|
+
import * as vue from 'vue';
|
|
3
|
+
|
|
4
|
+
declare const theme: {
|
|
5
|
+
extends: {
|
|
6
|
+
Layout: vue.DefineComponent;
|
|
7
|
+
enhanceApp: (ctx: vitepress.EnhanceAppContext) => void;
|
|
8
|
+
};
|
|
9
|
+
Layout: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>;
|
|
12
|
+
enhanceApp({ app, router, siteData }: vitepress.EnhanceAppContext): void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { theme as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/.vitepress/theme/index.ts
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import DefaultTheme from "vitepress/theme";
|
|
4
|
+
import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
|
|
5
|
+
import {
|
|
6
|
+
NolebaseEnhancedReadabilitiesMenu,
|
|
7
|
+
NolebaseEnhancedReadabilitiesScreenMenu,
|
|
8
|
+
InjectionKey,
|
|
9
|
+
LayoutMode
|
|
10
|
+
} from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
|
|
11
|
+
import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
|
|
12
|
+
import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
|
|
13
|
+
import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
|
|
14
|
+
import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
|
|
15
|
+
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
16
|
+
var theme = {
|
|
17
|
+
extends: DefaultTheme,
|
|
18
|
+
Layout: () => {
|
|
19
|
+
return h(DefaultTheme.Layout, null, {
|
|
20
|
+
// https://vitepress.dev/guide/extending-default-theme#layout-slots
|
|
21
|
+
"doc-before": () => h(NolebaseBreadcrumbs),
|
|
22
|
+
"nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
|
|
23
|
+
// 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
|
|
24
|
+
"nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
|
|
25
|
+
"layout-top": () => [h(NolebaseHighlightTargetedHeading)]
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
enhanceApp({ app, router, siteData }) {
|
|
29
|
+
app.use(NolebaseGitChangelogPlugin);
|
|
30
|
+
app.provide(InjectionKey, {
|
|
31
|
+
layoutSwitch: {
|
|
32
|
+
defaultMode: LayoutMode["BothWidthAdjustable"],
|
|
33
|
+
pageLayoutMaxWidth: {
|
|
34
|
+
defaultMaxWidth: 85
|
|
35
|
+
},
|
|
36
|
+
contentLayoutMaxWidth: {
|
|
37
|
+
defaultMaxWidth: 95
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var index_default = theme;
|
|
44
|
+
export {
|
|
45
|
+
index_default as default
|
|
46
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ruan-cat/vitepress-preset-config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "用于给大多数的vitepress项目提供一个预设的配置文件。",
|
|
5
|
+
"homepage": "https://utils.ruancat6312.top",
|
|
6
|
+
"types": "./src/config.mts",
|
|
7
|
+
"main": "./src/config.mts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@nolebase/vitepress-plugin-breadcrumbs": "^2.15.1",
|
|
10
|
+
"@nolebase/vitepress-plugin-enhanced-readabilities": "^2.15.1",
|
|
11
|
+
"@nolebase/vitepress-plugin-git-changelog": "^2.15.1",
|
|
12
|
+
"@nolebase/vitepress-plugin-highlight-targeted-heading": "^2.15.1",
|
|
13
|
+
"js-yaml": "^4.1.0",
|
|
14
|
+
"lodash-es": "^4.17.21",
|
|
15
|
+
"vitepress-demo-plugin": "^1.3.1",
|
|
16
|
+
"vitepress-sidebar": "^1.31.1",
|
|
17
|
+
"vue": "^3.5.13",
|
|
18
|
+
"@ruan-cat/utils": "^4.1.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/lodash-es": "^4.17.12",
|
|
22
|
+
"tsup": "^8.4.0",
|
|
23
|
+
"vitepress": "^1.6.3"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vitepress": "^1.6.x"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"vitepress": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/ruan-cat/vercel-monorepo-test/issues"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/ruan-cat/vercel-monorepo-test.git",
|
|
39
|
+
"directory": "packages/vitepress-preset-config"
|
|
40
|
+
},
|
|
41
|
+
"exports": {
|
|
42
|
+
"./config": {
|
|
43
|
+
"import": "./dist/config.mjs",
|
|
44
|
+
"types": "./src/config.mts"
|
|
45
|
+
},
|
|
46
|
+
"./theme": {
|
|
47
|
+
"import": "./dist/theme/index.mjs",
|
|
48
|
+
"types": "./src/.vitepress/theme/index.ts"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"vitepress"
|
|
53
|
+
],
|
|
54
|
+
"author": {
|
|
55
|
+
"name": "ruan-cat",
|
|
56
|
+
"email": "1219043956@qq.com",
|
|
57
|
+
"url": "https://github.com/ruan-cat"
|
|
58
|
+
},
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"registry": "https://registry.npmjs.org/",
|
|
63
|
+
"tag": "beta"
|
|
64
|
+
},
|
|
65
|
+
"typesVersions": {
|
|
66
|
+
"*": {
|
|
67
|
+
"*": [
|
|
68
|
+
"./dist/*",
|
|
69
|
+
"./*"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"dist",
|
|
75
|
+
"src",
|
|
76
|
+
"!src/tests",
|
|
77
|
+
"!src/**/tests",
|
|
78
|
+
"!src/**/*.md",
|
|
79
|
+
"!src/.vitepress/cache"
|
|
80
|
+
],
|
|
81
|
+
"scripts": {
|
|
82
|
+
"docs:dev": "vitepress dev src --port 8080",
|
|
83
|
+
"do-build-docs": "vitepress build src",
|
|
84
|
+
"build:docs": "turbo do-build-docs",
|
|
85
|
+
"do-build": "tsup",
|
|
86
|
+
"build": "turbo do-build"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// 避免直接使用自己的包
|
|
2
|
+
// import { setUserConfig, setGenerateSidebar, addChangelog2doc } from "@ruan-cat/vitepress-preset-config/config";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { setUserConfig, setGenerateSidebar, addChangelog2doc } from "../../src/config.mts";
|
|
5
|
+
|
|
6
|
+
addChangelog2doc({
|
|
7
|
+
target: "./src",
|
|
8
|
+
data: {
|
|
9
|
+
order: 1000,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 本文档的渲染配置
|
|
15
|
+
*/
|
|
16
|
+
const thisDocUserConfig = setUserConfig();
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
thisDocUserConfig.themeConfig.sidebar = setGenerateSidebar({
|
|
19
|
+
documentRootPath: "./src",
|
|
20
|
+
});
|
|
21
|
+
export default thisDocUserConfig;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// https://vitepress.dev/guide/custom-theme
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import type { Theme } from "vitepress";
|
|
4
|
+
import DefaultTheme from "vitepress/theme";
|
|
5
|
+
import "./style.css";
|
|
6
|
+
|
|
7
|
+
import { NolebaseBreadcrumbs } from "@nolebase/vitepress-plugin-breadcrumbs/client";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
NolebaseEnhancedReadabilitiesMenu,
|
|
11
|
+
NolebaseEnhancedReadabilitiesScreenMenu,
|
|
12
|
+
|
|
13
|
+
// https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/#如何在-vitepress-中进行配置
|
|
14
|
+
InjectionKey,
|
|
15
|
+
type Options,
|
|
16
|
+
LayoutMode,
|
|
17
|
+
} from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
|
|
18
|
+
import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
|
|
19
|
+
|
|
20
|
+
import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
|
|
21
|
+
import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
|
|
22
|
+
|
|
23
|
+
import { NolebaseGitChangelogPlugin } from "@nolebase/vitepress-plugin-git-changelog/client";
|
|
24
|
+
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
|
|
25
|
+
|
|
26
|
+
const theme = {
|
|
27
|
+
extends: DefaultTheme,
|
|
28
|
+
Layout: () => {
|
|
29
|
+
return h(DefaultTheme.Layout, null, {
|
|
30
|
+
// https://vitepress.dev/guide/extending-default-theme#layout-slots
|
|
31
|
+
|
|
32
|
+
"doc-before": () => h(NolebaseBreadcrumbs),
|
|
33
|
+
|
|
34
|
+
"nav-bar-content-after": () => h(NolebaseEnhancedReadabilitiesMenu),
|
|
35
|
+
// 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
|
|
36
|
+
"nav-screen-content-after": () => h(NolebaseEnhancedReadabilitiesScreenMenu),
|
|
37
|
+
|
|
38
|
+
"layout-top": () => [h(NolebaseHighlightTargetedHeading)],
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
enhanceApp({ app, router, siteData }) {
|
|
42
|
+
// ...
|
|
43
|
+
app.use(NolebaseGitChangelogPlugin);
|
|
44
|
+
|
|
45
|
+
app.provide(InjectionKey, {
|
|
46
|
+
layoutSwitch: {
|
|
47
|
+
defaultMode: LayoutMode["BothWidthAdjustable"],
|
|
48
|
+
pageLayoutMaxWidth: {
|
|
49
|
+
defaultMaxWidth: 85,
|
|
50
|
+
},
|
|
51
|
+
contentLayoutMaxWidth: {
|
|
52
|
+
defaultMaxWidth: 95,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
} as Options);
|
|
56
|
+
},
|
|
57
|
+
} satisfies Theme;
|
|
58
|
+
|
|
59
|
+
export default theme;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Customize default theme styling by overriding CSS variables:
|
|
3
|
+
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Colors
|
|
8
|
+
*
|
|
9
|
+
* Each colors have exact same color scale system with 3 levels of solid
|
|
10
|
+
* colors with different brightness, and 1 soft color.
|
|
11
|
+
*
|
|
12
|
+
* - `XXX-1`: The most solid color used mainly for colored text. It must
|
|
13
|
+
* satisfy the contrast ratio against when used on top of `XXX-soft`.
|
|
14
|
+
*
|
|
15
|
+
* - `XXX-2`: The color used mainly for hover state of the button.
|
|
16
|
+
*
|
|
17
|
+
* - `XXX-3`: The color for solid background, such as bg color of the button.
|
|
18
|
+
* It must satisfy the contrast ratio with pure white (#ffffff) text on
|
|
19
|
+
* top of it.
|
|
20
|
+
*
|
|
21
|
+
* - `XXX-soft`: The color used for subtle background such as custom container
|
|
22
|
+
* or badges. It must satisfy the contrast ratio when putting `XXX-1` colors
|
|
23
|
+
* on top of it.
|
|
24
|
+
*
|
|
25
|
+
* The soft color must be semi transparent alpha channel. This is crucial
|
|
26
|
+
* because it allows adding multiple "soft" colors on top of each other
|
|
27
|
+
* to create a accent, such as when having inline code block inside
|
|
28
|
+
* custom containers.
|
|
29
|
+
*
|
|
30
|
+
* - `default`: The color used purely for subtle indication without any
|
|
31
|
+
* special meanings attched to it such as bg color for menu hover state.
|
|
32
|
+
*
|
|
33
|
+
* - `brand`: Used for primary brand colors, such as link text, button with
|
|
34
|
+
* brand theme, etc.
|
|
35
|
+
*
|
|
36
|
+
* - `tip`: Used to indicate useful information. The default theme uses the
|
|
37
|
+
* brand color for this by default.
|
|
38
|
+
*
|
|
39
|
+
* - `warning`: Used to indicate warning to the users. Used in custom
|
|
40
|
+
* container, badges, etc.
|
|
41
|
+
*
|
|
42
|
+
* - `danger`: Used to show error, or dangerous message to the users. Used
|
|
43
|
+
* in custom container, badges, etc.
|
|
44
|
+
* -------------------------------------------------------------------------- */
|
|
45
|
+
|
|
46
|
+
:root {
|
|
47
|
+
--vp-c-default-1: var(--vp-c-gray-1);
|
|
48
|
+
--vp-c-default-2: var(--vp-c-gray-2);
|
|
49
|
+
--vp-c-default-3: var(--vp-c-gray-3);
|
|
50
|
+
--vp-c-default-soft: var(--vp-c-gray-soft);
|
|
51
|
+
|
|
52
|
+
--vp-c-brand-1: var(--vp-c-indigo-1);
|
|
53
|
+
--vp-c-brand-2: var(--vp-c-indigo-2);
|
|
54
|
+
--vp-c-brand-3: var(--vp-c-indigo-3);
|
|
55
|
+
--vp-c-brand-soft: var(--vp-c-indigo-soft);
|
|
56
|
+
|
|
57
|
+
--vp-c-tip-1: var(--vp-c-brand-1);
|
|
58
|
+
--vp-c-tip-2: var(--vp-c-brand-2);
|
|
59
|
+
--vp-c-tip-3: var(--vp-c-brand-3);
|
|
60
|
+
--vp-c-tip-soft: var(--vp-c-brand-soft);
|
|
61
|
+
|
|
62
|
+
--vp-c-warning-1: var(--vp-c-yellow-1);
|
|
63
|
+
--vp-c-warning-2: var(--vp-c-yellow-2);
|
|
64
|
+
--vp-c-warning-3: var(--vp-c-yellow-3);
|
|
65
|
+
--vp-c-warning-soft: var(--vp-c-yellow-soft);
|
|
66
|
+
|
|
67
|
+
--vp-c-danger-1: var(--vp-c-red-1);
|
|
68
|
+
--vp-c-danger-2: var(--vp-c-red-2);
|
|
69
|
+
--vp-c-danger-3: var(--vp-c-red-3);
|
|
70
|
+
--vp-c-danger-soft: var(--vp-c-red-soft);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Component: Button
|
|
75
|
+
* -------------------------------------------------------------------------- */
|
|
76
|
+
|
|
77
|
+
:root {
|
|
78
|
+
--vp-button-brand-border: transparent;
|
|
79
|
+
--vp-button-brand-text: var(--vp-c-white);
|
|
80
|
+
--vp-button-brand-bg: var(--vp-c-brand-3);
|
|
81
|
+
--vp-button-brand-hover-border: transparent;
|
|
82
|
+
--vp-button-brand-hover-text: var(--vp-c-white);
|
|
83
|
+
--vp-button-brand-hover-bg: var(--vp-c-brand-2);
|
|
84
|
+
--vp-button-brand-active-border: transparent;
|
|
85
|
+
--vp-button-brand-active-text: var(--vp-c-white);
|
|
86
|
+
--vp-button-brand-active-bg: var(--vp-c-brand-1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Component: Home
|
|
91
|
+
* -------------------------------------------------------------------------- */
|
|
92
|
+
|
|
93
|
+
:root {
|
|
94
|
+
--vp-home-hero-name-color: transparent;
|
|
95
|
+
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #bd34fe 30%, #41d1ff);
|
|
96
|
+
|
|
97
|
+
--vp-home-hero-image-background-image: linear-gradient(-45deg, #bd34fe 50%, #47caff 50%);
|
|
98
|
+
--vp-home-hero-image-filter: blur(44px);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@media (min-width: 640px) {
|
|
102
|
+
:root {
|
|
103
|
+
--vp-home-hero-image-filter: blur(56px);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (min-width: 960px) {
|
|
108
|
+
:root {
|
|
109
|
+
--vp-home-hero-image-filter: blur(68px);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Component: Custom Block
|
|
115
|
+
* -------------------------------------------------------------------------- */
|
|
116
|
+
|
|
117
|
+
:root {
|
|
118
|
+
--vp-custom-block-tip-border: transparent;
|
|
119
|
+
--vp-custom-block-tip-text: var(--vp-c-text-1);
|
|
120
|
+
--vp-custom-block-tip-bg: var(--vp-c-brand-soft);
|
|
121
|
+
--vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Component: Algolia
|
|
126
|
+
* -------------------------------------------------------------------------- */
|
|
127
|
+
|
|
128
|
+
.DocSearch {
|
|
129
|
+
--docsearch-primary-color: var(--vp-c-brand-1) !important;
|
|
130
|
+
}
|
package/src/config.mts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { defineConfig, type DefaultTheme, type UserConfig } from "vitepress";
|
|
2
|
+
import { generateSidebar, withSidebar } from "vitepress-sidebar";
|
|
3
|
+
|
|
4
|
+
export { defineConfig };
|
|
5
|
+
|
|
6
|
+
import { GitChangelog, GitChangelogMarkdownSection } from "@nolebase/vitepress-plugin-git-changelog/vite";
|
|
7
|
+
import { vitepressDemoPlugin } from "vitepress-demo-plugin";
|
|
8
|
+
|
|
9
|
+
import { merge, isUndefined, cloneDeep } from "lodash-es";
|
|
10
|
+
|
|
11
|
+
import { addChangelog2doc } from "@ruan-cat/utils/node-esm";
|
|
12
|
+
export { addChangelog2doc };
|
|
13
|
+
|
|
14
|
+
/** 默认侧边栏配置 */
|
|
15
|
+
const defaultSidebarOptions: VitePressSidebarOptions = {
|
|
16
|
+
// documentRootPath: "src",
|
|
17
|
+
|
|
18
|
+
// 侧边栏需要折叠
|
|
19
|
+
collapsed: true,
|
|
20
|
+
|
|
21
|
+
// 不需要配置折叠嵌套深度
|
|
22
|
+
// collapseDepth: 4,
|
|
23
|
+
|
|
24
|
+
// 不需要索引首页 首页直接在标题内找到即可
|
|
25
|
+
// includeRootIndexFile: true,
|
|
26
|
+
|
|
27
|
+
// 不需要索引文件夹
|
|
28
|
+
// includeFolderIndexFile: true,
|
|
29
|
+
|
|
30
|
+
// 用文件的 h1 标题作为侧边栏标题
|
|
31
|
+
useTitleFromFileHeading: true,
|
|
32
|
+
|
|
33
|
+
// 用index文件的标题作为折叠栏的标题
|
|
34
|
+
useFolderTitleFromIndexFile: true,
|
|
35
|
+
|
|
36
|
+
// 折叠栏链接到index文件
|
|
37
|
+
useFolderLinkFromIndexFile: true,
|
|
38
|
+
|
|
39
|
+
// 用order字段做菜单排序
|
|
40
|
+
sortMenusByFrontmatterOrder: true,
|
|
41
|
+
|
|
42
|
+
// 不使用倒序排序
|
|
43
|
+
// sortMenusOrderByDescending: true,
|
|
44
|
+
sortMenusByName: false,
|
|
45
|
+
|
|
46
|
+
useFolderLinkFromSameNameSubFile: true,
|
|
47
|
+
|
|
48
|
+
debugPrint: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** 获得合并后的侧边栏配置 */
|
|
52
|
+
function getMergeSidebarOptions(options?: VitePressSidebarOptions) {
|
|
53
|
+
return merge({}, cloneDeep(defaultSidebarOptions), isUndefined(options) ? {} : options);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 设置自动生成侧边栏的配置
|
|
58
|
+
* @see https://vitepress-sidebar.cdget.com/zhHans/guide/options
|
|
59
|
+
*/
|
|
60
|
+
export function setGenerateSidebar(options?: VitePressSidebarOptions) {
|
|
61
|
+
return generateSidebar(getMergeSidebarOptions(options));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 默认用户配置 */
|
|
65
|
+
const defaultUserConfig: UserConfig<DefaultTheme.Config> = {
|
|
66
|
+
title: "10wms前端组技术文档",
|
|
67
|
+
description: "本前端项目内的组件使用、api、类型以及使用文档",
|
|
68
|
+
|
|
69
|
+
lang: "zh",
|
|
70
|
+
// 暂不需要
|
|
71
|
+
// srcDir: "./src",
|
|
72
|
+
|
|
73
|
+
themeConfig: {
|
|
74
|
+
i18nRouting: true,
|
|
75
|
+
|
|
76
|
+
search: {
|
|
77
|
+
provider: "local",
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// https://vitepress.dev/reference/default-theme-config
|
|
81
|
+
nav: [
|
|
82
|
+
{ text: "首页", link: "/" },
|
|
83
|
+
{ text: "更新日志", link: "/CHANGELOG.md" },
|
|
84
|
+
// TODO: 未来项目结束时,在此补充配置
|
|
85
|
+
// { text: "仓库地址", link: "https://github.com/ruan-cat/vercel-monorepo-test/tree/dev/packages/docs-01-star" },
|
|
86
|
+
],
|
|
87
|
+
|
|
88
|
+
outline: {
|
|
89
|
+
label: "本页目录",
|
|
90
|
+
level: "deep",
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// 自动化侧边栏
|
|
94
|
+
sidebar: setGenerateSidebar(),
|
|
95
|
+
|
|
96
|
+
socialLinks: [
|
|
97
|
+
{
|
|
98
|
+
icon: "github",
|
|
99
|
+
link: "https://github.com/ruan-cat/vercel-monorepo-test/blob/dev/packages/docs-01-star/docs/index.md",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
vite: {
|
|
105
|
+
server: {
|
|
106
|
+
open: true,
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
plugins: [
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
GitChangelog({
|
|
112
|
+
// 填写在此处填写您的仓库链接
|
|
113
|
+
repoURL: () => "https://github.com/ruan-cat/vercel-monorepo-test",
|
|
114
|
+
}),
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
GitChangelogMarkdownSection(),
|
|
117
|
+
],
|
|
118
|
+
|
|
119
|
+
optimizeDeps: {
|
|
120
|
+
exclude: [
|
|
121
|
+
"@nolebase/vitepress-plugin-breadcrumbs/client",
|
|
122
|
+
"@nolebase/vitepress-plugin-enhanced-readabilities/client",
|
|
123
|
+
"vitepress",
|
|
124
|
+
"@nolebase/ui",
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
ssr: {
|
|
129
|
+
noExternal: [
|
|
130
|
+
// 如果还有别的依赖需要添加的话,并排填写和配置到这里即可
|
|
131
|
+
"@nolebase/vitepress-plugin-breadcrumbs",
|
|
132
|
+
|
|
133
|
+
"@nolebase/vitepress-plugin-enhanced-readabilities",
|
|
134
|
+
"@nolebase/ui",
|
|
135
|
+
|
|
136
|
+
"@nolebase/vitepress-plugin-highlight-targeted-heading",
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
markdown: {
|
|
142
|
+
config(md) {
|
|
143
|
+
md.use(vitepressDemoPlugin);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** 设置vitepress主配置 */
|
|
149
|
+
export function setUserConfig(config?: UserConfig<DefaultTheme.Config>) {
|
|
150
|
+
return merge({}, cloneDeep(defaultUserConfig), isUndefined(config) ? {} : config);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
type VitePressSidebarOptions = Parameters<typeof generateSidebar>[0];
|
|
154
|
+
|
|
155
|
+
// TODO:
|
|
156
|
+
/** 设置导航栏的变更日志 */
|
|
157
|
+
function handleChangeLog() {}
|