@vuepress/theme-default 2.0.0-beta.36 → 2.0.0-beta.37

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.
@@ -9,6 +9,14 @@ export default defineClientAppEnhance(({ app, router }) => {
9
9
  app.component('Badge', Badge);
10
10
  app.component('CodeGroup', CodeGroup);
11
11
  app.component('CodeGroupItem', CodeGroupItem);
12
+ // compat with @vuepress/plugin-external-link-icon
13
+ app.component('AutoLinkExternalIcon', () => {
14
+ const ExternalLinkIcon = app.component('ExternalLinkIcon');
15
+ if (ExternalLinkIcon) {
16
+ return h(ExternalLinkIcon);
17
+ }
18
+ return null;
19
+ });
12
20
  // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
13
21
  app.component('NavbarSearch', () => {
14
22
  const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
@@ -107,7 +107,7 @@ const isActive = computed(() => {
107
107
  >
108
108
  <slot name="before" />
109
109
  {{ item.text }}
110
- <ExternalLinkIcon v-if="isBlankTarget" />
110
+ <AutoLinkExternalIcon v-if="isBlankTarget" />
111
111
  <slot name="after" />
112
112
  </a>
113
113
  </template>
@@ -1,8 +1,46 @@
1
1
  <script setup lang="ts">
2
2
  import SidebarItem from '@theme/SidebarItem.vue'
3
+ import { watch } from 'vue'
4
+ import { useRoute } from 'vue-router'
3
5
  import { useSidebarItems } from '../composables'
4
6
 
7
+ const route = useRoute()
5
8
  const sidebarItems = useSidebarItems()
9
+
10
+ watch(
11
+ () => route.hash,
12
+ (hash) => {
13
+ // get the sidebar DOM
14
+ const sidebar = document.querySelector('.sidebar')
15
+ if (!sidebar) return
16
+
17
+ // get the active sidebar item DOM, whose href equals to the current route
18
+ const activeSidebarItem = document.querySelector(
19
+ `.sidebar a.sidebar-item[href="${route.path}${hash}"]`
20
+ )
21
+ if (!activeSidebarItem) return
22
+
23
+ // get the top and height of the sidebar
24
+ const sidebarTop = sidebar.getBoundingClientRect().top
25
+ const sidebarHeight = sidebar.getBoundingClientRect().height
26
+
27
+ // get the top and height of the active sidebar item
28
+ const activeSidebarItemTop = activeSidebarItem.getBoundingClientRect().top
29
+ const activeSidebarItemHeight =
30
+ activeSidebarItem.getBoundingClientRect().height
31
+
32
+ if (activeSidebarItemTop < sidebarTop) {
33
+ // scroll to the top edge of sidebar when the active sidebar item overflows the top edge of sidebar
34
+ activeSidebarItem.scrollIntoView(true)
35
+ } else if (
36
+ activeSidebarItemTop + activeSidebarItemHeight >
37
+ sidebarTop + sidebarHeight
38
+ ) {
39
+ // scroll to the bottom edge of sidebar when the active sidebar item overflows the bottom edge of sidebar
40
+ activeSidebarItem.scrollIntoView(false)
41
+ }
42
+ }
43
+ )
6
44
  </script>
7
45
 
8
46
  <template>
package/lib/node/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.36",
3
+ "version": "2.0.0-beta.37",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -30,28 +30,28 @@
30
30
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
31
31
  },
32
32
  "dependencies": {
33
- "@vuepress/client": "2.0.0-beta.35",
34
- "@vuepress/core": "2.0.0-beta.36",
35
- "@vuepress/plugin-active-header-links": "2.0.0-beta.36",
36
- "@vuepress/plugin-back-to-top": "2.0.0-beta.36",
37
- "@vuepress/plugin-container": "2.0.0-beta.36",
38
- "@vuepress/plugin-external-link-icon": "2.0.0-beta.36",
39
- "@vuepress/plugin-git": "2.0.0-beta.36",
40
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.36",
41
- "@vuepress/plugin-nprogress": "2.0.0-beta.36",
42
- "@vuepress/plugin-palette": "2.0.0-beta.36",
43
- "@vuepress/plugin-prismjs": "2.0.0-beta.36",
44
- "@vuepress/plugin-theme-data": "2.0.0-beta.36",
45
- "@vuepress/shared": "2.0.0-beta.35",
46
- "@vuepress/utils": "2.0.0-beta.35",
47
- "@vueuse/core": "^7.5.4",
48
- "sass": "^1.49.0",
49
- "sass-loader": "^12.4.0",
50
- "vue": "^3.2.28",
51
- "vue-router": "^4.0.12"
33
+ "@vuepress/client": "2.0.0-beta.37",
34
+ "@vuepress/core": "2.0.0-beta.37",
35
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.37",
36
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.37",
37
+ "@vuepress/plugin-container": "2.0.0-beta.37",
38
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.37",
39
+ "@vuepress/plugin-git": "2.0.0-beta.37",
40
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.37",
41
+ "@vuepress/plugin-nprogress": "2.0.0-beta.37",
42
+ "@vuepress/plugin-palette": "2.0.0-beta.37",
43
+ "@vuepress/plugin-prismjs": "2.0.0-beta.37",
44
+ "@vuepress/plugin-theme-data": "2.0.0-beta.37",
45
+ "@vuepress/shared": "2.0.0-beta.37",
46
+ "@vuepress/utils": "2.0.0-beta.37",
47
+ "@vueuse/core": "^8.2.1",
48
+ "sass": "^1.49.10",
49
+ "sass-loader": "^12.6.0",
50
+ "vue": "^3.2.31",
51
+ "vue-router": "^4.0.14"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "275ac05052de642e698bc0fb7fad61fce702a978"
56
+ "gitHead": "6600a8c1a293b948be977c348eb9907178bb3263"
57
57
  }