Skip to content

Commit 079dd35

Browse files
authored
Merge pull request #184 from 142vip/feat/vitepress-type
feat: 简化`vitepress`博客配置和类型,移除`element-plus`组件的手动导入
2 parents d07700c + 767a8f1 commit 079dd35

File tree

4 files changed

+9
-32
lines changed

4 files changed

+9
-32
lines changed

.vitepress/config.ts

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

99
/**
1010
* 导航栏
1111
*/
12-
const navbarConfig: DefaultTheme.NavItem[] = [
12+
const navbarConfig: NavbarConfig = [
1313
{
1414
text: '🔥 首页',
1515
link: '/docs/index.md',

.vitepress/sidebar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { VipProject } from '@142vip/vitepress'
1+
import type { SidebarConfig, VipProject } from '@142vip/vitepress'
22
import type { DefaultTheme } from 'vitepress/types/default-theme'
33
import { pick } from '@142vip/vitepress'
44

@@ -14,7 +14,7 @@ enum ProjectId {
1414
/**
1515
* 侧边栏
1616
*/
17-
export const sidebarConfig: DefaultTheme.SidebarItem[] = [
17+
export const sidebarConfig: SidebarConfig = [
1818
{
1919
text: `🏆 ${ProjectId.Infra}`,
2020
items: [

.vitepress/theme/components/HomePage.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
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
import { getCoreProjectData, getExampleDemoTableData } from '../../sidebar'
1211
1312
const { isDark } = useData()
1413
const coreProjectTableData = ref<any[]>([])
1514
const exampleDemoTableData = ref()
1615
17-
defineComponent({
18-
components: {
19-
ElImage,
20-
},
21-
})
22-
2316
/**
2417
* 异步加载表格数据
2518
*/
@@ -87,14 +80,14 @@ onMounted(async () => {
8780
<h2>趋势</h2>
8881
<!-- 支持黑色主题 -->
8982
<div class="star-history">
90-
<ElImage
83+
<img
9184
:src="`https://api.star-history.com/svg?repos=142vip/core-x,142vip/408CSFamily,142vip/JavaScriptCollection&type=Date${
9285
isDark ? '&theme=dark' : ''
9386
}`"
9487
class="img-border"
9588
alt="Github Star History"
9689
title="Github Star History"
97-
/>
90+
>
9891
</div>
9992
</section>
10093

.vitepress/theme/index.ts

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)