Skip to content

Commit 402f73f

Browse files
docs: ✏️ 调整文档结构增加文档内容可用宽度,支持收起演示demo (#765)
1 parent b06a7a7 commit 402f73f

90 files changed

Lines changed: 2809 additions & 985 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/.vitepress/config.mts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/*
22
* @Author: weisheng
33
* @Date: 2023-07-27 10:26:09
4-
* @LastEditTime: 2024-11-09 21:52:24
4+
* @LastEditTime: 2024-12-07 15:20:53
55
* @LastEditors: weisheng
66
* @Description:
77
* @FilePath: /wot-design-uni/docs/.vitepress/config.mts
88
* 记得注释
99
*/
1010
import { defineConfig } from 'vitepress';
1111
import viteCompression from 'vite-plugin-compression'
12+
import { fileURLToPath, URL } from 'node:url'
1213

1314
import { MarkdownTransform } from './plugins/markdown-transform'
1415

@@ -25,7 +26,41 @@ export default defineConfig({
2526
ext: '.gz',
2627
})
2728
],
28-
ssr: { noExternal: ['element-plus'] }
29+
ssr: { noExternal: ['element-plus'] },
30+
resolve: {
31+
alias: [
32+
{
33+
find: /^.*\/VPSidebar\.vue$/,
34+
replacement: fileURLToPath(
35+
new URL('./theme/components/VPSidebar.vue', import.meta.url)
36+
)
37+
},
38+
{
39+
find: /^.*\/VPContent\.vue$/,
40+
replacement: fileURLToPath(
41+
new URL('./theme/components/VPContent.vue', import.meta.url)
42+
)
43+
},
44+
{
45+
find: /^.*\/VPDoc\.vue$/,
46+
replacement: fileURLToPath(
47+
new URL('./theme/components/VPDoc.vue', import.meta.url)
48+
)
49+
},
50+
{
51+
find: /^.*\/VPLocalNav\.vue$/,
52+
replacement: fileURLToPath(
53+
new URL('./theme/components/VPLocalNav.vue', import.meta.url)
54+
)
55+
},
56+
{
57+
find: /^.*\/VPNavBar\.vue$/,
58+
replacement: fileURLToPath(
59+
new URL('./theme/components/VPNavBar.vue', import.meta.url)
60+
)
61+
}
62+
]
63+
}
2964
},
3065
title: `Wot Design Uni`,
3166
description: '一个参照wot-design打造的uni-app组件库',

docs/.vitepress/plugins/markdown-transform.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { Plugin } from 'vite'
1+
2+
import { Plugin } from 'vite';
23
import { camelCase } from '../../../src/uni_modules/wot-design-uni/components/common/util'
34
import path from 'path'
45
export function MarkdownTransform(): Plugin {
@@ -7,7 +8,7 @@ export function MarkdownTransform(): Plugin {
78
enforce: 'pre',
89
async transform(code, id) {
910
if (!id.endsWith('.md')) return
10-
if (!code.includes('<frame/>')) return
11+
if (!id.includes('/component')) return
1112
const GITHUB_URL = 'https://github.com/Moonofweisheng/wot-design-uni/tree/master'
1213
const componentId = path.basename(id, '.md')
1314
const componentName = `wd-${componentId}`

docs/.vitepress/theme/components/CustomFooter.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<!--
22
* @Author: weisheng
33
* @Date: 2024-01-07 00:46:50
4-
* @LastEditTime: 2024-01-07 01:57:00
4+
* @LastEditTime: 2024-12-07 14:23:56
55
* @LastEditors: weisheng
66
* @Description:
77
* @FilePath: /wot-design-uni/docs/.vitepress/theme/components/CustomFooter.vue
88
* 记得注释
99
-->
1010
<script setup lang="ts">
11-
import { useData } from 'vitepress/dist/client/theme-default/composables/data';
12-
import { useSidebar } from 'vitepress/dist/client/theme-default/composables/sidebar';
1311
import { computed, onMounted, ref } from 'vue';
12+
import { useData} from 'vitepress'
13+
import { useSidebar } from 'vitepress/theme'
1414
15-
16-
const { theme } = useData()
15+
const { theme }:any = useData()
1716
const { hasSidebar } = useSidebar()
1817
1918
const isNetlify = ref<boolean>(false)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!--
2+
* @Author: weisheng
3+
* @Date: 2024-12-07 18:41:41
4+
* @LastEditTime: 2024-12-07 21:28:08
5+
* @LastEditors: weisheng
6+
* @Description:
7+
* @FilePath: /wot-design-uni/docs/.vitepress/theme/components/VPContent.vue
8+
* 记得注释
9+
-->
10+
<script setup lang="ts">
11+
import { useData } from 'vitepress';
12+
import NotFound from 'vitepress/dist/client/theme-default//NotFound.vue'
13+
import VPDoc from './VPDoc.vue'
14+
import VPHome from 'vitepress/dist/client/theme-default/components/VPHome.vue'
15+
import VPPage from 'vitepress/dist/client/theme-default/components/VPPage.vue'
16+
import { useSidebar } from 'vitepress/theme';
17+
18+
19+
const { page, frontmatter }:any = useData()
20+
const { hasSidebar } = useSidebar()
21+
</script>
22+
23+
<template>
24+
<div
25+
class="VPContent"
26+
id="VPContent"
27+
:class="{
28+
'has-sidebar': hasSidebar,
29+
'is-home': frontmatter.layout === 'home'
30+
}"
31+
>
32+
<slot name="not-found" v-if="page.isNotFound"><NotFound /></slot>
33+
34+
<VPPage v-else-if="frontmatter.layout === 'page'">
35+
<template #page-top><slot name="page-top" /></template>
36+
<template #page-bottom><slot name="page-bottom" /></template>
37+
</VPPage>
38+
39+
<VPHome v-else-if="frontmatter.layout === 'home'">
40+
<template #home-hero-before><slot name="home-hero-before" /></template>
41+
<template #home-hero-info-before><slot name="home-hero-info-before" /></template>
42+
<template #home-hero-info><slot name="home-hero-info" /></template>
43+
<template #home-hero-info-after><slot name="home-hero-info-after" /></template>
44+
<template #home-hero-actions-after><slot name="home-hero-actions-after" /></template>
45+
<template #home-hero-image><slot name="home-hero-image" /></template>
46+
<template #home-hero-after><slot name="home-hero-after" /></template>
47+
<template #home-features-before><slot name="home-features-before" /></template>
48+
<template #home-features-after><slot name="home-features-after" /></template>
49+
</VPHome>
50+
51+
<component
52+
v-else-if="frontmatter.layout && frontmatter.layout !== 'doc'"
53+
:is="frontmatter.layout"
54+
/>
55+
56+
<VPDoc v-else>
57+
<template #doc-top><slot name="doc-top" /></template>
58+
<template #doc-bottom><slot name="doc-bottom" /></template>
59+
60+
<template #doc-footer-before><slot name="doc-footer-before" /></template>
61+
<template #doc-before><slot name="doc-before" /></template>
62+
<template #doc-after><slot name="doc-after" /></template>
63+
64+
<template #aside-top><slot name="aside-top" /></template>
65+
<template #aside-outline-before><slot name="aside-outline-before" /></template>
66+
<template #aside-outline-after><slot name="aside-outline-after" /></template>
67+
<template #aside-ads-before><slot name="aside-ads-before" /></template>
68+
<template #aside-ads-after><slot name="aside-ads-after" /></template>
69+
<template #aside-bottom><slot name="aside-bottom" /></template>
70+
</VPDoc>
71+
</div>
72+
</template>
73+
74+
<style scoped>
75+
.VPContent {
76+
flex-grow: 1;
77+
flex-shrink: 0;
78+
margin: var(--vp-layout-top-height, 0px) auto 0;
79+
width: 100%;
80+
}
81+
82+
.VPContent.is-home {
83+
width: 100%;
84+
max-width: 100%;
85+
}
86+
87+
.VPContent.has-sidebar {
88+
margin: 0;
89+
}
90+
91+
.VPNavBar.container{
92+
max-width: none;
93+
}
94+
95+
@media (min-width: 960px) {
96+
.VPContent {
97+
padding-top: var(--vp-nav-height);
98+
}
99+
100+
.VPContent.has-sidebar {
101+
margin: var(--vp-layout-top-height, 0px) 0 0;
102+
padding-left: var(--vp-sidebar-width);
103+
}
104+
}
105+
</style>
106+
107+

0 commit comments

Comments
 (0)