Skip to content

Commit 362bcc2

Browse files
committed
build: 升级 @142vip/vuepress0.0.1-alpha.25 并对齐包内用法
改用 `createVipViteBuildPlugin`,侧栏类型直接引用包导出,去掉本地重复插件与主题默认项冗余配置。
1 parent 1d01bec commit 362bcc2

6 files changed

Lines changed: 42 additions & 515 deletions

File tree

.vuepress/config/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/** 站点配置统一导出入口 */
22
export * from './footer'
3-
export * from './plugins/vite-build.plugin'
43
export * from './seo'
54
export * from './sidebar'
65
export * from './sidebar.resolve'

.vuepress/config/plugins/vite-build.plugin.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

.vuepress/config/sidebar.resolve.ts

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
1+
import type {
2+
DocsSidebarConfig,
3+
DocsSidebarGroup,
4+
DocsSidebarItem,
5+
} from '@142vip/vuepress'
16
import type { AutoLinkOptions, SidebarItemOptions } from 'vuepress-theme-hope'
27
import { VipNodeJS } from '@142vip/utils'
38

4-
/** 侧边栏直链项 */
5-
export interface DocsSidebarLink {
6-
text: string
7-
link: string
8-
}
9-
10-
/** 侧边栏分组项 */
11-
export interface DocsSidebarGroup {
12-
text: string
13-
prefix?: string
14-
link?: string
15-
collapsible?: boolean
16-
expanded?: boolean
17-
children: DocsSidebarItem[]
18-
}
19-
20-
export type DocsSidebarItem = DocsSidebarLink | DocsSidebarGroup
21-
22-
export type DocsSidebarConfig = DocsSidebarItem[]
23-
24-
function isSidebarGroup(item: DocsSidebarItem): item is DocsSidebarGroup {
25-
return Array.isArray((item as DocsSidebarGroup).children)
26-
}
27-
289
function readPermalink(mdFilePath: string): string | null {
2910
if (!VipNodeJS.existPath(mdFilePath)) {
3011
return null
@@ -59,6 +40,8 @@ function resolveMdLink(
5940
* 本仓库大量页面 permalink 与文件名不一致(如 `html.md` → `/front-end/base-begin/html-correlation.html`),
6041
* 故在配置阶段按文件解析并替换 `link`;无法单靠 `vuepress.config.ts` 原生选项完成。
6142
*
43+
* 侧栏结构类型见 `@142vip/vuepress` 的 `DocsSidebar*`;本函数为站点侧解析工具。
44+
*
6245
* @param sidebar 模块侧边栏原始配置(可含 `.md` 链接)
6346
* @param docsBasePath `docs/` 下的相对目录,如 `server-end/framework/egg`
6447
*/
@@ -68,14 +51,15 @@ export function resolveSidebarPermalinks(
6851
): SidebarItemOptions[] {
6952
const walk = (items: DocsSidebarItem[], groupPrefix = ''): SidebarItemOptions[] =>
7053
items.map((item) => {
71-
if (isSidebarGroup(item)) {
54+
if (Array.isArray((item as DocsSidebarGroup).children)) {
55+
const group = item as DocsSidebarGroup
7256
return {
73-
...item,
74-
children: walk(item.children, item.prefix ?? ''),
57+
...group,
58+
children: walk(group.children, group.prefix ?? ''),
7559
}
7660
}
7761

78-
if (!item.link.endsWith('.md')) {
62+
if (!item.link?.endsWith('.md')) {
7963
return item as AutoLinkOptions
8064
}
8165

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"clean:hooks": "npx fa clean --git-hooks --all --ignore-tips",
2222
"lint": "npx fa lint",
2323
"lint:fix": "npx fa lint --fix",
24-
"dev": "npx vuepress dev",
25-
"build": "npx vuepress build --clean-temp --clean-cache",
26-
"build:proxy": "NEED_PROXY=true npx vuepress build --clean-temp --clean-cache",
24+
"dev": "vuepress dev",
25+
"build": "vuepress build --clean-temp --clean-cache",
26+
"build:proxy": "NEED_PROXY=true vuepress build --clean-temp --clean-cache",
2727
"release": "npx fa release --vip --check-branch next --check-branch main",
2828
"check:commit": "npx node --loader ts-node/esm --no-warnings scripts/core/verify-commit.ts"
2929
},
@@ -33,7 +33,7 @@
3333
"@142vip/fairy-cli": "0.0.3-alpha.33",
3434
"@142vip/open-source": "0.0.1-alpha.4",
3535
"@142vip/utils": "0.0.1-alpha.58",
36-
"@142vip/vuepress": "0.0.1-alpha.24",
36+
"@142vip/vuepress": "0.0.1-alpha.25",
3737
"only-allow": "1.2.1",
3838
"simple-git-hooks": "2.13.0",
3939
"ts-node": "10.9.2"

0 commit comments

Comments
 (0)