Skip to content

Commit 0bf7c90

Browse files
微信公众号:储凡mmdapl
andauthored
feat(vuepress-demo): 引入@142vip/utils模块,调整Demo基本结构和主题配置 (#157)
* feat(vuepress-demo): 引入`@142vip/utils`模块,调整`Demo`基本结构 * chore: update --------- Co-authored-by: chufan <mmdapl@163.com>
1 parent 4ae3147 commit 0bf7c90

File tree

8 files changed

+58
-44
lines changed

8 files changed

+58
-44
lines changed

apps/vuepress-demo/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## 介绍
44

5+
```bash
6+
# 在项目根目录下载依赖
7+
pnpm i
8+
9+
# 切换到vuepress-demo根目录
10+
cd apps/vuepress-demo
11+
12+
# 本地启动
13+
pnpm dev
14+
15+
# 本地编译
16+
pnpm build
17+
```
18+
519
## 证书
620

721
[MIT](https://opensource.org/license/MIT)

apps/vuepress-demo/docs/.vuepress/theme/READEME.md

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

apps/vuepress-demo/docs/.vuepress/theme/sidebar.ts

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

apps/vuepress-demo/docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pnpm i @vuepress/bundler-vite@2.0.0-rc.17 -D
3636
3737
# 安装@142vip/vuepress模块
3838
pnpm i @142vip/vuepress -D
39+
40+
# 安装@142vip/utils模块
41+
pnpm i @142vip/utils -D
3942
```
4043

4144
## 基本使用

apps/vuepress-demo/docs/.vuepress/theme/navbar.ts renamed to apps/vuepress-demo/docs/theme.config.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { navbar } from 'vuepress-theme-hope'
1+
import { navbar, sidebar } from 'vuepress-theme-hope'
22

33
/**
4-
* 导航栏配置
4+
* 导航栏
55
*/
6-
export default navbar([
6+
export const navbarConfig = navbar([
77
{
88
text: '🌐 首页',
99
link: '/',
@@ -49,3 +49,30 @@ export default navbar([
4949
],
5050
},
5151
])
52+
53+
/**
54+
* 侧边栏
55+
*/
56+
export const sidebarConfig = sidebar({
57+
'/example': [
58+
{
59+
text: '示例文档',
60+
// prefix: 'example',
61+
collapsible: false,
62+
children: [
63+
{
64+
text: '示例文档-1',
65+
link: 'test-1.md',
66+
},
67+
{
68+
text: '示例文档-2',
69+
link: 'test-2.md',
70+
},
71+
{
72+
text: '示例文档-3',
73+
link: 'test-3.md',
74+
},
75+
],
76+
},
77+
],
78+
})

apps/vuepress-demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build": "vuepress build docs"
1717
},
1818
"devDependencies": {
19+
"@142vip/utils": "workspace:*",
1920
"@142vip/vuepress": "workspace:*",
2021
"@vuepress/bundler-vite": "2.0.0-rc.17",
2122
"vuepress": "2.0.0-rc.17"

apps/vuepress-demo/vuepress.config.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@ import {
77
exampleHeaders,
88
getCopyRightText,
99
getFooterHtml,
10-
getSiteBase,
1110
getThemeConfig,
1211
getViteBundler,
1312
} from '@142vip/vuepress'
14-
import navbar from './docs/.vuepress/theme/navbar'
15-
import sidebar from './docs/.vuepress/theme/sidebar'
13+
import { getDocSiteBase } from '@142vip/utils'
1614

17-
// 当前目录名
18-
const __dirname = getDirname(import.meta.url)
15+
import { navbarConfig, sidebarConfig } from './docs/theme.config'
1916

2017
const pkg = createRequire(import.meta.url)('./package.json')
2118

2219
export default defineUserConfig({
23-
base: getSiteBase(),
20+
base: getDocSiteBase(''),
2421
title: pkg.name,
2522
description: pkg.description,
2623
port: 5200,
@@ -30,6 +27,8 @@ export default defineUserConfig({
3027
// todo 引入代码文件时的路径替换 https://vuejs.press/zh/guide/markdown.html#%E5%AF%BC%E5%85%A5%E4%BB%A3%E7%A0%81%E5%9D%97
3128
importCode: {
3229
handleImportPath: (str) => {
30+
// 当前目录名
31+
const __dirname = getDirname(import.meta.url)
3332
if (str.includes('@code')) {
3433
return str.replace(/^@code/, path.resolve(__dirname, 'code/'))
3534
}
@@ -47,9 +46,9 @@ export default defineUserConfig({
4746
// 主题配置
4847
theme: hopeTheme(getThemeConfig({
4948
// 导航栏
50-
navbar,
49+
navbar: navbarConfig,
5150
// 侧边栏
52-
sidebar,
51+
sidebar: sidebarConfig,
5352
// 页脚
5453
footer: getFooterHtml({
5554
name: pkg.name,

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)