@vuepress/theme-default 2.0.0-beta.45 → 2.0.0-beta.46
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/Page.vue +4 -0
- package/lib/client/components/SidebarItems.vue +34 -31
- package/lib/client/components/global/CodeGroup.d.ts +1 -2
- package/lib/client/components/global/CodeGroup.js +1 -1
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/config.js +1 -3
- package/lib/client/layouts/Layout.vue +6 -0
- package/lib/client/styles/normalize.scss +1 -1
- package/package.json +17 -17
|
@@ -1,46 +1,49 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import SidebarItem from '@theme/SidebarItem.vue'
|
|
3
|
-
import { watch } from 'vue'
|
|
3
|
+
import { onMounted, watch } from 'vue'
|
|
4
4
|
import { useRoute } from 'vue-router'
|
|
5
5
|
import { useSidebarItems } from '../composables'
|
|
6
6
|
|
|
7
7
|
const route = useRoute()
|
|
8
8
|
const sidebarItems = useSidebarItems()
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
watch(
|
|
12
|
+
() => route.hash,
|
|
13
|
+
(hash) => {
|
|
14
|
+
// get the sidebar DOM
|
|
15
|
+
const sidebar = document.querySelector('.sidebar')
|
|
16
|
+
if (!sidebar) return
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// get the active sidebar item DOM, whose href equals to the current route
|
|
19
|
+
const activeSidebarItem = document.querySelector(
|
|
20
|
+
`.sidebar a.sidebar-item[href="${route.path}${hash}"]`
|
|
21
|
+
)
|
|
22
|
+
if (!activeSidebarItem) return
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// get the top and height of the sidebar
|
|
25
|
+
const { top: sidebarTop, height: sidebarHeight } =
|
|
26
|
+
sidebar.getBoundingClientRect()
|
|
27
|
+
// get the top and height of the active sidebar item
|
|
28
|
+
const { top: activeSidebarItemTop, height: activeSidebarItemHeight } =
|
|
29
|
+
activeSidebarItem.getBoundingClientRect()
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
activeSidebarItem.scrollIntoView(false)
|
|
31
|
+
// when the active sidebar item overflows the top edge of sidebar
|
|
32
|
+
if (activeSidebarItemTop < sidebarTop) {
|
|
33
|
+
// scroll to the top edge of sidebar
|
|
34
|
+
activeSidebarItem.scrollIntoView(true)
|
|
35
|
+
}
|
|
36
|
+
// when the active sidebar item overflows the bottom edge of sidebar
|
|
37
|
+
else if (
|
|
38
|
+
activeSidebarItemTop + activeSidebarItemHeight >
|
|
39
|
+
sidebarTop + sidebarHeight
|
|
40
|
+
) {
|
|
41
|
+
// scroll to the bottom edge of sidebar
|
|
42
|
+
activeSidebarItem.scrollIntoView(false)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
)
|
|
45
|
+
)
|
|
46
|
+
})
|
|
44
47
|
</script>
|
|
45
48
|
|
|
46
49
|
<template>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
declare const
|
|
2
|
+
export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
5
|
-
export default _default;
|
package/lib/client/config.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { defineClientConfig } from '@vuepress/client';
|
|
2
2
|
import { h } from 'vue';
|
|
3
|
-
import Badge from './components/global
|
|
4
|
-
import CodeGroup from './components/global/CodeGroup';
|
|
5
|
-
import CodeGroupItem from './components/global/CodeGroupItem.vue';
|
|
3
|
+
import { Badge, CodeGroup, CodeGroupItem } from './components/global';
|
|
6
4
|
import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables';
|
|
7
5
|
import './styles/index.scss';
|
|
8
6
|
export default defineClientConfig({
|
|
@@ -118,6 +118,12 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
118
118
|
<template #top>
|
|
119
119
|
<slot name="page-top" />
|
|
120
120
|
</template>
|
|
121
|
+
<template #content-top>
|
|
122
|
+
<slot name="page-content-top" />
|
|
123
|
+
</template>
|
|
124
|
+
<template #content-bottom>
|
|
125
|
+
<slot name="page-content-bottom" />
|
|
126
|
+
</template>
|
|
121
127
|
<template #bottom>
|
|
122
128
|
<slot name="page-bottom" />
|
|
123
129
|
</template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.46",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -25,27 +25,27 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vuepress/client": "2.0.0-beta.
|
|
29
|
-
"@vuepress/core": "2.0.0-beta.
|
|
30
|
-
"@vuepress/plugin-active-header-links": "2.0.0-beta.
|
|
31
|
-
"@vuepress/plugin-back-to-top": "2.0.0-beta.
|
|
32
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
33
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-beta.
|
|
34
|
-
"@vuepress/plugin-git": "2.0.0-beta.
|
|
35
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-beta.
|
|
36
|
-
"@vuepress/plugin-nprogress": "2.0.0-beta.
|
|
37
|
-
"@vuepress/plugin-palette": "2.0.0-beta.
|
|
38
|
-
"@vuepress/plugin-prismjs": "2.0.0-beta.
|
|
39
|
-
"@vuepress/plugin-theme-data": "2.0.0-beta.
|
|
40
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
41
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
28
|
+
"@vuepress/client": "2.0.0-beta.46",
|
|
29
|
+
"@vuepress/core": "2.0.0-beta.46",
|
|
30
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.46",
|
|
31
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.46",
|
|
32
|
+
"@vuepress/plugin-container": "2.0.0-beta.46",
|
|
33
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.46",
|
|
34
|
+
"@vuepress/plugin-git": "2.0.0-beta.46",
|
|
35
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.46",
|
|
36
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.46",
|
|
37
|
+
"@vuepress/plugin-palette": "2.0.0-beta.46",
|
|
38
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.46",
|
|
39
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.46",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.46",
|
|
41
|
+
"@vuepress/utils": "2.0.0-beta.46",
|
|
42
42
|
"@vueuse/core": "^8.4.2",
|
|
43
43
|
"sass": "^1.51.0",
|
|
44
|
-
"vue": "^3.2.
|
|
44
|
+
"vue": "^3.2.35",
|
|
45
45
|
"vue-router": "^4.0.15"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"sass-loader": "^
|
|
48
|
+
"sass-loader": "^13.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"sass-loader": {
|