@vuepress/theme-default 2.0.0-rc.79 → 2.0.0-rc.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/components/VPDropdownTransition.vue +7 -0
- package/lib/client/components/VPFadeSlideYTransition.vue +43 -0
- package/lib/client/components/VPNavbarDropdown.vue +5 -9
- package/lib/client/components/VPSidebarItem.vue +11 -5
- package/lib/client/composables/useHeaders.js +9 -5
- package/lib/client/composables/useNavigate.js +1 -1
- package/lib/client/composables/useRelatedLinks.js +6 -6
- package/lib/client/composables/useSidebarItems.js +5 -3
- package/lib/client/config.js +2 -0
- package/lib/client/layouts/Layout.vue +10 -40
- package/lib/client/styles/layout.scss +4 -0
- package/lib/node/defaultTheme.js +1 -6
- package/package.json +15 -15
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VNode } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineEmits<{
|
|
5
|
+
beforeEnter: []
|
|
6
|
+
beforeLeave: []
|
|
7
|
+
}>()
|
|
8
|
+
defineSlots<{
|
|
9
|
+
default: () => VNode | string | null
|
|
10
|
+
}>()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<Transition
|
|
15
|
+
name="vp-fade-slide-y"
|
|
16
|
+
mode="out-in"
|
|
17
|
+
@before-enter="$emit('beforeEnter')"
|
|
18
|
+
@before-leave="$emit('beforeLeave')"
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</Transition>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style lang="scss">
|
|
25
|
+
/**
|
|
26
|
+
* fade-slide-y transition
|
|
27
|
+
*/
|
|
28
|
+
.vp-fade-slide-y {
|
|
29
|
+
&-enter-active {
|
|
30
|
+
transition: all 0.2s ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-leave-active {
|
|
34
|
+
transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-enter-from,
|
|
38
|
+
&-leave-to {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transform: translateY(-10px);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
3
3
|
import VPDropdownTransition from '@theme/VPDropdownTransition.vue'
|
|
4
4
|
import { useToggle } from '@vueuse/core'
|
|
5
|
-
import { computed, toRefs
|
|
6
|
-
import {
|
|
5
|
+
import { computed, toRefs } from 'vue'
|
|
6
|
+
import { onContentUpdated } from 'vuepress/client'
|
|
7
7
|
import type { AutoLinkOptions, NavGroup } from '../../shared/index.js'
|
|
8
8
|
|
|
9
9
|
const props = defineProps<{
|
|
@@ -12,7 +12,6 @@ const props = defineProps<{
|
|
|
12
12
|
}>()
|
|
13
13
|
|
|
14
14
|
const { config } = toRefs(props)
|
|
15
|
-
const route = useRoute()
|
|
16
15
|
|
|
17
16
|
const [open, toggleOpen] = useToggle(false)
|
|
18
17
|
|
|
@@ -36,12 +35,9 @@ const handleDropdown = (e: UIEvent): void => {
|
|
|
36
35
|
else toggleOpen(false)
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
()
|
|
41
|
-
|
|
42
|
-
toggleOpen(false)
|
|
43
|
-
},
|
|
44
|
-
)
|
|
38
|
+
onContentUpdated(() => {
|
|
39
|
+
toggleOpen(false)
|
|
40
|
+
})
|
|
45
41
|
</script>
|
|
46
42
|
|
|
47
43
|
<template>
|
|
@@ -5,7 +5,7 @@ import { isActiveSidebarItem } from '@theme/isActiveSidebarItem'
|
|
|
5
5
|
import { useToggle } from '@vueuse/core'
|
|
6
6
|
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
7
7
|
import { useRoute, useRouter } from 'vuepress/client'
|
|
8
|
-
import type { SidebarItem } from '../typings.js'
|
|
8
|
+
import type { SidebarGroupItem, SidebarItem } from '../typings.js'
|
|
9
9
|
|
|
10
10
|
const props = withDefaults(
|
|
11
11
|
defineProps<{
|
|
@@ -25,9 +25,7 @@ const { item, depth } = toRefs(props)
|
|
|
25
25
|
const route = useRoute()
|
|
26
26
|
const router = useRouter()
|
|
27
27
|
|
|
28
|
-
const collapsible = computed(
|
|
29
|
-
() => 'collapsible' in item.value && item.value.collapsible,
|
|
30
|
-
)
|
|
28
|
+
const collapsible = computed(() => (item.value as SidebarGroupItem).collapsible)
|
|
31
29
|
const isActive = computed(() => isActiveSidebarItem(item.value, route))
|
|
32
30
|
const itemClass = computed(() => ({
|
|
33
31
|
'vp-sidebar-item': true,
|
|
@@ -62,7 +60,15 @@ onBeforeUnmount(() => {
|
|
|
62
60
|
|
|
63
61
|
<template>
|
|
64
62
|
<li>
|
|
65
|
-
<VPAutoLink v-if="item.link" :class="itemClass" :config="item"
|
|
63
|
+
<VPAutoLink v-if="item.link" :class="itemClass" :config="item">
|
|
64
|
+
<template #after>
|
|
65
|
+
<span
|
|
66
|
+
v-if="collapsible"
|
|
67
|
+
class="arrow"
|
|
68
|
+
:class="isOpen ? 'down' : 'right'"
|
|
69
|
+
/>
|
|
70
|
+
</template>
|
|
71
|
+
</VPAutoLink>
|
|
66
72
|
<p
|
|
67
73
|
v-else
|
|
68
74
|
tabindex="0"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useData } from '@theme/useData';
|
|
2
2
|
import { getHeaders } from '@vuepress/helper/client';
|
|
3
|
-
import { injectLocal, provideLocal
|
|
4
|
-
import { computed,
|
|
3
|
+
import { injectLocal, provideLocal } from '@vueuse/core';
|
|
4
|
+
import { computed, ref } from 'vue';
|
|
5
|
+
import { onContentUpdated } from 'vuepress/client';
|
|
5
6
|
export const headersSymbol = Symbol('headers');
|
|
6
7
|
/**
|
|
7
8
|
* Inject headers
|
|
@@ -14,7 +15,7 @@ export const useHeaders = () => {
|
|
|
14
15
|
return headers;
|
|
15
16
|
};
|
|
16
17
|
export const setupHeaders = () => {
|
|
17
|
-
const { frontmatter,
|
|
18
|
+
const { frontmatter, themeLocale } = useData();
|
|
18
19
|
const headersRef = ref([]);
|
|
19
20
|
const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
|
|
20
21
|
const updateHeaders = () => {
|
|
@@ -28,7 +29,10 @@ export const setupHeaders = () => {
|
|
|
28
29
|
});
|
|
29
30
|
};
|
|
30
31
|
provideLocal(headersSymbol, headersRef);
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
onContentUpdated((reason) => {
|
|
33
|
+
if (reason === 'beforeUnmount')
|
|
34
|
+
headersRef.value = [];
|
|
35
|
+
else
|
|
36
|
+
updateHeaders();
|
|
33
37
|
});
|
|
34
38
|
};
|
|
@@ -2,7 +2,7 @@ import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
|
2
2
|
import { useData } from '@theme/useData';
|
|
3
3
|
import { useSidebarItems } from '@theme/useSidebarItems';
|
|
4
4
|
import { computed } from 'vue';
|
|
5
|
-
import { resolveRoute,
|
|
5
|
+
import { resolveRoute, useRoutePath } from 'vuepress/client';
|
|
6
6
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
7
7
|
const resolveFromFrontmatterConfig = (config, currentPath) => {
|
|
8
8
|
if (config === false) {
|
|
@@ -64,24 +64,24 @@ const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
|
|
|
64
64
|
export const useRelatedLinks = () => {
|
|
65
65
|
const { frontmatter, themeLocale } = useData();
|
|
66
66
|
const sidebarItems = useSidebarItems();
|
|
67
|
-
const
|
|
67
|
+
const routePath = useRoutePath();
|
|
68
68
|
const prevLink = computed(() => {
|
|
69
|
-
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev,
|
|
69
|
+
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev, routePath.value);
|
|
70
70
|
return prevConfig === false
|
|
71
71
|
? null
|
|
72
72
|
: (prevConfig ??
|
|
73
73
|
(themeLocale.value.prev === false
|
|
74
74
|
? null
|
|
75
|
-
: resolveFromSidebarItems(sidebarItems.value,
|
|
75
|
+
: resolveFromSidebarItems(sidebarItems.value, routePath.value, -1)));
|
|
76
76
|
});
|
|
77
77
|
const nextLink = computed(() => {
|
|
78
|
-
const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next,
|
|
78
|
+
const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next, routePath.value);
|
|
79
79
|
return nextConfig === false
|
|
80
80
|
? null
|
|
81
81
|
: (nextConfig ??
|
|
82
82
|
(themeLocale.value.next === false
|
|
83
83
|
? null
|
|
84
|
-
: resolveFromSidebarItems(sidebarItems.value,
|
|
84
|
+
: resolveFromSidebarItems(sidebarItems.value, routePath.value, 1)));
|
|
85
85
|
});
|
|
86
86
|
return {
|
|
87
87
|
prevLink,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
2
|
import { resolvePrefix } from '@theme/resolvePrefix';
|
|
3
3
|
import { useData } from '@theme/useData';
|
|
4
|
+
import { useHeaders } from '@theme/useHeaders';
|
|
4
5
|
import { isLinkRelative, keys, startsWith } from '@vuepress/helper/client';
|
|
5
6
|
import { computed, inject, provide } from 'vue';
|
|
6
|
-
import {
|
|
7
|
+
import { useRoutePath } from 'vuepress/client';
|
|
7
8
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
8
9
|
/**
|
|
9
10
|
* Util to transform page header to sidebar item
|
|
@@ -115,12 +116,13 @@ export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, head
|
|
|
115
116
|
*/
|
|
116
117
|
export const setupSidebarItems = () => {
|
|
117
118
|
const { frontmatter, page, routeLocale, themeLocale } = useData();
|
|
118
|
-
const
|
|
119
|
+
const headers = useHeaders();
|
|
120
|
+
const routePath = useRoutePath();
|
|
119
121
|
const sidebarConfig = computed(() => frontmatter.value.home
|
|
120
122
|
? false
|
|
121
123
|
: (frontmatter.value.sidebar ??
|
|
122
124
|
themeLocale.value.sidebar ??
|
|
123
125
|
'heading'));
|
|
124
|
-
const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value,
|
|
126
|
+
const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, routePath.value, routeLocale.value, headers.value));
|
|
125
127
|
provide(sidebarItemsSymbol, sidebarItems);
|
|
126
128
|
};
|
package/lib/client/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setupDarkMode } from '@theme/useDarkMode';
|
|
2
|
+
import { setupHeaders } from '@theme/useHeaders';
|
|
2
3
|
import { useScrollPromise } from '@theme/useScrollPromise';
|
|
3
4
|
import { setupSidebarItems } from '@theme/useSidebarItems';
|
|
4
5
|
import { hasGlobalComponent } from '@vuepress/helper/client';
|
|
@@ -22,6 +23,7 @@ export default defineClientConfig({
|
|
|
22
23
|
},
|
|
23
24
|
setup() {
|
|
24
25
|
setupDarkMode();
|
|
26
|
+
setupHeaders();
|
|
25
27
|
setupSidebarItems();
|
|
26
28
|
},
|
|
27
29
|
layouts: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPFadeSlideYTransition from '@theme/VPFadeSlideYTransition.vue'
|
|
2
3
|
import VPHome from '@theme/VPHome.vue'
|
|
3
4
|
import VPNavbar from '@theme/VPNavbar.vue'
|
|
4
5
|
import VPPage from '@theme/VPPage.vue'
|
|
@@ -7,8 +8,8 @@ import { useData } from '@theme/useData'
|
|
|
7
8
|
import { useScrollPromise } from '@theme/useScrollPromise'
|
|
8
9
|
import { useSidebarItems } from '@theme/useSidebarItems'
|
|
9
10
|
import type { VNode } from 'vue'
|
|
10
|
-
import { computed,
|
|
11
|
-
import {
|
|
11
|
+
import { computed, ref } from 'vue'
|
|
12
|
+
import { onContentUpdated } from 'vuepress/client'
|
|
12
13
|
|
|
13
14
|
defineSlots<{
|
|
14
15
|
'navbar'?: (props: Record<never, never>) => VNode | VNode[] | null
|
|
@@ -27,7 +28,6 @@ defineSlots<{
|
|
|
27
28
|
}>()
|
|
28
29
|
|
|
29
30
|
const { frontmatter, page, themeLocale } = useData()
|
|
30
|
-
const router = useRouter()
|
|
31
31
|
|
|
32
32
|
// navbar
|
|
33
33
|
const shouldShowNavbar = computed(
|
|
@@ -77,16 +77,9 @@ const containerClass = computed(() => [
|
|
|
77
77
|
frontmatter.value.pageClass,
|
|
78
78
|
])
|
|
79
79
|
|
|
80
|
-
// close sidebar
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
onMounted(() => {
|
|
84
|
-
unregisterRouterHook = router.afterEach(() => {
|
|
85
|
-
toggleSidebar(false)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
onUnmounted(() => {
|
|
89
|
-
unregisterRouterHook()
|
|
80
|
+
// close sidebar when content changes
|
|
81
|
+
onContentUpdated(() => {
|
|
82
|
+
toggleSidebar(false)
|
|
90
83
|
})
|
|
91
84
|
|
|
92
85
|
// handle scrollBehavior with transition
|
|
@@ -128,16 +121,12 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
128
121
|
</slot>
|
|
129
122
|
|
|
130
123
|
<slot name="page">
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
<Transition
|
|
134
|
-
v-else
|
|
135
|
-
name="fade-slide-y"
|
|
136
|
-
mode="out-in"
|
|
124
|
+
<VPFadeSlideYTransition
|
|
137
125
|
@before-enter="onBeforeEnter"
|
|
138
126
|
@before-leave="onBeforeLeave"
|
|
139
127
|
>
|
|
140
|
-
<
|
|
128
|
+
<VPHome v-if="frontmatter.home" />
|
|
129
|
+
<VPPage v-else :key="page.path">
|
|
141
130
|
<template #top>
|
|
142
131
|
<slot name="page-top" />
|
|
143
132
|
</template>
|
|
@@ -151,7 +140,7 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
151
140
|
<slot name="page-bottom" />
|
|
152
141
|
</template>
|
|
153
142
|
</VPPage>
|
|
154
|
-
</
|
|
143
|
+
</VPFadeSlideYTransition>
|
|
155
144
|
</slot>
|
|
156
145
|
</div>
|
|
157
146
|
</template>
|
|
@@ -230,23 +219,4 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
230
219
|
}
|
|
231
220
|
}
|
|
232
221
|
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* fade-slide-y transition
|
|
236
|
-
*/
|
|
237
|
-
.fade-slide-y {
|
|
238
|
-
&-enter-active {
|
|
239
|
-
transition: all 0.2s ease;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
&-leave-active {
|
|
243
|
-
transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
&-enter-from,
|
|
247
|
-
&-leave-to {
|
|
248
|
-
opacity: 0;
|
|
249
|
-
transform: translateY(10px);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
222
|
</style>
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -101,12 +101,7 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
|
|
|
101
101
|
: {})
|
|
102
102
|
: [],
|
|
103
103
|
// @vuepress/plugin-medium-zoom
|
|
104
|
-
themePlugins.mediumZoom !== false
|
|
105
|
-
? mediumZoomPlugin({
|
|
106
|
-
// should greater than page transition duration
|
|
107
|
-
delay: 300,
|
|
108
|
-
})
|
|
109
|
-
: [],
|
|
104
|
+
themePlugins.mediumZoom !== false ? mediumZoomPlugin() : [],
|
|
110
105
|
// @vuepress/plugin-nprogress
|
|
111
106
|
themePlugins.nprogress !== false ? nprogressPlugin() : [],
|
|
112
107
|
// @vuepress/plugin-palette
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.80",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"templates"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
41
|
-
"@vuepress/plugin-active-header-links": "2.0.0-rc.
|
|
42
|
-
"@vuepress/plugin-back-to-top": "2.0.0-rc.
|
|
43
|
-
"@vuepress/plugin-copy-code": "2.0.0-rc.
|
|
40
|
+
"@vuepress/helper": "2.0.0-rc.80",
|
|
41
|
+
"@vuepress/plugin-active-header-links": "2.0.0-rc.80",
|
|
42
|
+
"@vuepress/plugin-back-to-top": "2.0.0-rc.80",
|
|
43
|
+
"@vuepress/plugin-copy-code": "2.0.0-rc.80",
|
|
44
44
|
"@vuepress/plugin-git": "2.0.0-rc.79",
|
|
45
|
-
"@vuepress/plugin-links-check": "2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-markdown-hint": "2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-markdown-tab": "2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-nprogress": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-palette": "2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-prismjs": "2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-seo": "2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-sitemap": "2.0.0-rc.
|
|
45
|
+
"@vuepress/plugin-links-check": "2.0.0-rc.80",
|
|
46
|
+
"@vuepress/plugin-markdown-hint": "2.0.0-rc.80",
|
|
47
|
+
"@vuepress/plugin-markdown-tab": "2.0.0-rc.80",
|
|
48
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-rc.80",
|
|
49
|
+
"@vuepress/plugin-nprogress": "2.0.0-rc.80",
|
|
50
|
+
"@vuepress/plugin-palette": "2.0.0-rc.80",
|
|
51
|
+
"@vuepress/plugin-prismjs": "2.0.0-rc.80",
|
|
52
|
+
"@vuepress/plugin-seo": "2.0.0-rc.80",
|
|
53
|
+
"@vuepress/plugin-sitemap": "2.0.0-rc.80",
|
|
54
54
|
"@vuepress/plugin-theme-data": "2.0.0-rc.79",
|
|
55
55
|
"@vueuse/core": "^12.7.0",
|
|
56
56
|
"vue": "^3.5.13"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "22fd3a41e96cbfef599673f1421452cd0d7e0d9d"
|
|
79
79
|
}
|