Skip to content

Commit c79eb1e

Browse files
committed
feat(vitepress-demo): 优化导航栏、侧边栏配置
1 parent 46a6029 commit c79eb1e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

apps/vitepress-demo/.vitepress/config.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import type { NavbarConfig, SidebarConfig } from '@142vip/vitepress'
2-
import { getDocSiteBase, OPEN_SOURCE_ADDRESS, VipNodeJS } from '@142vip/utils'
3-
import { defineVipVitepressConfig, getVipFooter, getVipThemeConfig, zhSearch } from '@142vip/vitepress'
4-
import { name as pkgName, version as pkgVersion } from '../package.json'
1+
import { getDocSiteBase, OPEN_SOURCE_ADDRESS, VipNodeJS, VipPackageJSON } from '@142vip/utils'
2+
import {
3+
defineVipNavbarConfig,
4+
defineVipSidebarConfig,
5+
defineVipVitepressConfig,
6+
getVipFooter,
7+
getVipThemeConfig,
8+
zhSearch,
9+
} from '@142vip/vitepress'
10+
11+
const pkg = VipPackageJSON.getPackageJSON<{ description: string }>()
512

613
/**
714
* 导航栏
815
*/
9-
const navbarConfig: NavbarConfig = [
16+
const navbarConfig = defineVipNavbarConfig([
1017
{ text: '🔥 首页', link: '/docs/index.md' },
1118
{
1219
text: '💻 示例文档',
@@ -17,7 +24,7 @@ const navbarConfig: NavbarConfig = [
1724
],
1825
},
1926
{
20-
text: `⚡ ${pkgVersion}`,
27+
text: `⚡ ${pkg.version}`,
2128
items: [
2229
{ text: '🎉 历史版本', link: `${OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X}/releases` },
2330
{ text: '📄 更新日志', link: `${OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X}/blob/main/CHANGELOG.md` },
@@ -30,12 +37,12 @@ const navbarConfig: NavbarConfig = [
3037
},
3138
],
3239
},
33-
]
40+
])
3441

3542
/**
3643
* 侧边栏
3744
*/
38-
const sidebarConfig: SidebarConfig = [
45+
const sidebarConfig = defineVipSidebarConfig([
3946
{
4047
text: '示例文档',
4148
collapsed: false,
@@ -45,7 +52,7 @@ const sidebarConfig: SidebarConfig = [
4552
{ text: '示例文档-3', link: '/docs/example/test-3.md' },
4653
],
4754
},
48-
]
55+
])
4956

5057
/**
5158
* 所有配置
@@ -71,7 +78,7 @@ export default defineVipVitepressConfig({
7178
['meta', { property: 'og:url', content: 'https://github.com/142vip/core-x' }],
7279
['meta', { property: 'og:type', content: 'website' }],
7380
['meta', { property: 'og:title', content: '@142vip/core-x' }],
74-
['meta', { property: 'og:description', content: `${pkgName} - @142vip/vitepress-demo演示项目` }],
81+
['meta', { property: 'og:description', content: `${pkg.name} - @142vip/vitepress-demo演示项目` }],
7582
],
7683
// markdown
7784
markdown: {
@@ -94,8 +101,8 @@ export default defineVipVitepressConfig({
94101
// 页脚
95102
footer: getVipFooter({
96103
license: OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X,
97-
pkgName,
98-
pkgVersion,
104+
pkgName: pkg.name,
105+
pkgVersion: pkg.version,
99106
orgLink: OPEN_SOURCE_ADDRESS.HOME_PAGE_GITHUB_VIP,
100107
ownerLink: OPEN_SOURCE_ADDRESS.HOME_PAGE_GITHUB_MMDAPL,
101108
}),

0 commit comments

Comments
 (0)