Skip to content

Commit d07700c

Browse files
committed
feat(vitepress-demo): 简化Demo配置,移除element-plus组件的手动导入
1 parent 52a0eff commit d07700c

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import path from 'node:path'
22
import { defineConfig } from 'vitepress'
33
import { getThemeConfig, getVipFooter, zhSearch } from '@142vip/vitepress'
44
import { OPEN_SOURCE_ADDRESS, getDocSiteBase } from '@142vip/utils'
5-
import type { DefaultTheme } from 'vitepress/types/default-theme'
5+
import type { NavbarConfig, SidebarConfig } from '@142vip/vitepress'
66
import { name as pkgName, version as pkgVersion } from '../package.json'
77

88
/**
99
* 导航栏
1010
*/
11-
const navbarConfig: DefaultTheme.NavItem[] = [
11+
const navbarConfig: NavbarConfig = [
1212
{ text: '🔥 首页', link: '/docs/index.md' },
1313
{
1414
text: '💻 示例文档',
@@ -37,7 +37,7 @@ const navbarConfig: DefaultTheme.NavItem[] = [
3737
/**
3838
* 侧边栏
3939
*/
40-
const sidebarConfig: DefaultTheme.SidebarItem[] = [
40+
const sidebarConfig: SidebarConfig = [
4141
{
4242
text: '示例文档',
4343
collapsed: false,

apps/vitepress-demo/.vitepress/theme/components/HomePage.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
<script lang="ts" setup>
2-
import { defineComponent, onMounted, ref } from 'vue'
2+
import { onMounted, ref } from 'vue'
33
import {
44
VipBackTop,
55
VipContactAuthor,
66
VipProjectTable,
77
VipTeam,
88
} from '@142vip/vitepress/components'
99
import { useData } from 'vitepress'
10-
import { ElImage } from 'element-plus'
1110
1211
const { isDark } = useData()
1312
const tableData = ref<any[]>([])
1413
15-
defineComponent({
16-
components: {
17-
ElImage,
18-
},
19-
})
20-
2114
/**
2215
* 异步加载表格数据
2316
*/
@@ -83,14 +76,14 @@ onMounted(async () => {
8376
<h2>趋势</h2>
8477
<!-- 支持黑色主题 -->
8578
<div class="star-history">
86-
<ElImage
79+
<img
8780
:src="`https://api.star-history.com/svg?repos=142vip/core-x,142vip/408CSFamily,142vip/JavaScriptCollection&type=Date${
8881
isDark ? '&theme=dark' : ''
8982
}`"
9083
alt="Github Star History"
9184
class="img-border"
9285
title="Github Star History"
93-
/>
86+
>
9487
</div>
9588
</section>
9689

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
import { h } from 'vue'
2-
import DefaultTheme from 'vitepress/theme'
1+
import defineVipExtendsTheme from '@142vip/vitepress/theme'
32
import './style.css'
4-
import type { Theme } from 'vitepress'
5-
import { VipBackTop } from '@142vip/vitepress/components'
6-
// 导入 element-plus样式
7-
// import 'element-plus/dist/index.css'
83

94
/**
105
* 自定义主题
116
* 参考: https://vitepress.dev/guide/custom-theme
127
*/
13-
export default {
14-
extends: DefaultTheme,
15-
Layout: () => {
16-
return h(DefaultTheme.Layout, null, {
17-
// https://vitepress.dev/guide/extending-default-theme#layout-slots
18-
'doc-bottom': () => h(VipBackTop),
19-
})
20-
},
21-
// todo 查看这里的app、router、siteData的作用
22-
enhanceApp() {
23-
},
24-
} satisfies Theme
8+
export default defineVipExtendsTheme()

0 commit comments

Comments
 (0)