Skip to content

feat(vitepress-demo): 优化导航栏、侧边栏配置 #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions apps/vitepress-demo/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import type { NavbarConfig, SidebarConfig } from '@142vip/vitepress'
import { getDocSiteBase, OPEN_SOURCE_ADDRESS, VipNodeJS } from '@142vip/utils'
import { defineVipVitepressConfig, getVipFooter, getVipThemeConfig, zhSearch } from '@142vip/vitepress'
import { name as pkgName, version as pkgVersion } from '../package.json'
import { getDocSiteBase, OPEN_SOURCE_ADDRESS, VipNodeJS, VipPackageJSON } from '@142vip/utils'
import {
defineVipNavbarConfig,
defineVipSidebarConfig,
defineVipVitepressConfig,
getVipFooter,
getVipThemeConfig,
zhSearch,
} from '@142vip/vitepress'

const pkg = VipPackageJSON.getPackageJSON<{ description: string }>()

/**
* 导航栏
*/
const navbarConfig: NavbarConfig = [
const navbarConfig = defineVipNavbarConfig([
{ text: '🔥 首页', link: '/docs/index.md' },
{
text: '💻 示例文档',
Expand All @@ -17,7 +24,7 @@ const navbarConfig: NavbarConfig = [
],
},
{
text: `⚡ ${pkgVersion}`,
text: `⚡ ${pkg.version}`,
items: [
{ text: '🎉 历史版本', link: `${OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X}/releases` },
{ text: '📄 更新日志', link: `${OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X}/blob/main/CHANGELOG.md` },
Expand All @@ -30,12 +37,12 @@ const navbarConfig: NavbarConfig = [
},
],
},
]
])

/**
* 侧边栏
*/
const sidebarConfig: SidebarConfig = [
const sidebarConfig = defineVipSidebarConfig([
{
text: '示例文档',
collapsed: false,
Expand All @@ -45,7 +52,7 @@ const sidebarConfig: SidebarConfig = [
{ text: '示例文档-3', link: '/docs/example/test-3.md' },
],
},
]
])

/**
* 所有配置
Expand All @@ -71,7 +78,7 @@ export default defineVipVitepressConfig({
['meta', { property: 'og:url', content: 'https://github.com/142vip/core-x' }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:title', content: '@142vip/core-x' }],
['meta', { property: 'og:description', content: `${pkgName} - @142vip/vitepress-demo演示项目` }],
['meta', { property: 'og:description', content: `${pkg.name} - @142vip/vitepress-demo演示项目` }],
],
// markdown
markdown: {
Expand All @@ -94,8 +101,8 @@ export default defineVipVitepressConfig({
// 页脚
footer: getVipFooter({
license: OPEN_SOURCE_ADDRESS.GITHUB_REPO_CORE_X,
pkgName,
pkgVersion,
pkgName: pkg.name,
pkgVersion: pkg.version,
orgLink: OPEN_SOURCE_ADDRESS.HOME_PAGE_GITHUB_VIP,
ownerLink: OPEN_SOURCE_ADDRESS.HOME_PAGE_GITHUB_MMDAPL,
}),
Expand Down
Loading