@vuepress/theme-default 2.0.0-beta.48 → 2.0.0-beta.49

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.
@@ -27,12 +27,16 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
27
27
  }
28
28
  const currentPath = router.currentRoute.value.path
29
29
  const currentFullPath = router.currentRoute.value.fullPath
30
+ const currentHash = router.currentRoute.value.hash
30
31
 
31
32
  const languageDropdown: ResolvedNavbarItem = {
32
33
  text: themeLocale.value.selectLanguageText ?? 'unknown language',
33
- ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
34
+ ariaLabel:
35
+ themeLocale.value.selectLanguageAriaLabel ??
36
+ themeLocale.value.selectLanguageText ??
37
+ 'unknown language',
34
38
  children: localePaths.map((targetLocalePath) => {
35
- // target locale config of this langauge link
39
+ // target locale config of this language link
36
40
  const targetSiteLocale =
37
41
  siteLocale.value.locales?.[targetLocalePath] ?? {}
38
42
  const targetThemeLocale =
@@ -57,7 +61,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
57
61
  if (
58
62
  router.getRoutes().some((item) => item.path === targetLocalePage)
59
63
  ) {
60
- link = targetLocalePage
64
+ // try to keep current hash across languages
65
+ link = `${targetLocalePage}${currentHash}`
61
66
  } else {
62
67
  link = targetThemeLocale.home ?? targetLocalePath
63
68
  }
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
3
  import DropdownTransition from '@theme/DropdownTransition.vue'
4
- import { computed, ref, toRefs } from 'vue'
4
+ import { useToggle } from '@vueuse/core'
5
+ import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
5
6
  import type { PropType } from 'vue'
6
7
  import { useRoute, useRouter } from 'vue-router'
7
8
  import type { ResolvedSidebarItem } from '../../shared'
@@ -31,21 +32,24 @@ const itemClass = computed(() => ({
31
32
  'collapsible': item.value.collapsible,
32
33
  }))
33
34
 
34
- const isOpen = ref(true)
35
- const onClick = ref<(() => void) | undefined>(undefined)
36
-
37
- if (item.value.collapsible) {
38
- // active item is open by default
39
- isOpen.value = isActive.value
40
- // toggle open status on click
41
- onClick.value = () => {
42
- isOpen.value = !isOpen.value
35
+ const [isOpen, toggleIsOpen] = useToggle(isActive.value)
36
+ const onClick = (e: Event): void => {
37
+ if (item.value.collapsible) {
38
+ e.preventDefault()
39
+ // toggle open status on click
40
+ toggleIsOpen()
43
41
  }
44
- // reset open status after navigation
45
- router.afterEach(() => {
46
- isOpen.value = isActive.value
47
- })
48
42
  }
43
+
44
+ // reset open status after navigation
45
+ const unregisterRouterHook = router.afterEach((to) => {
46
+ nextTick(() => {
47
+ isOpen.value = item.value.collapsible ? isActive.value : true
48
+ })
49
+ })
50
+ onBeforeUnmount(() => {
51
+ unregisterRouterHook()
52
+ })
49
53
  </script>
50
54
 
51
55
  <template>
@@ -50,7 +50,7 @@ onMounted(() => {
50
50
  <ul v-if="sidebarItems.length" class="sidebar-items">
51
51
  <SidebarItem
52
52
  v-for="item in sidebarItems"
53
- :key="item.link || item.text"
53
+ :key="`${item.text}${item.link}`"
54
54
  :item="item"
55
55
  />
56
56
  </ul>
@@ -14,12 +14,14 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
14
14
 
15
15
  <template>
16
16
  <div class="theme-container">
17
- <div class="theme-default-content">
18
- <h1>404</h1>
17
+ <main class="page">
18
+ <div class="theme-default-content">
19
+ <h1>404</h1>
19
20
 
20
- <blockquote>{{ getMsg() }}</blockquote>
21
+ <blockquote>{{ getMsg() }}</blockquote>
21
22
 
22
- <RouterLink :to="homeLink">{{ homeText }}</RouterLink>
23
- </div>
23
+ <RouterLink :to="homeLink">{{ homeText }}</RouterLink>
24
+ </div>
25
+ </main>
24
26
  </div>
25
27
  </template>
@@ -129,6 +129,7 @@ a.header-anchor {
129
129
  padding-right: 0.23em;
130
130
  margin-top: 0.125em;
131
131
  opacity: 0;
132
+ user-select: none;
132
133
 
133
134
  &:hover {
134
135
  text-decoration: none;
@@ -79,20 +79,20 @@
79
79
  box-sizing: border-box;
80
80
  margin: 0;
81
81
 
82
+ + .sidebar-item-children {
83
+ @include dropdown_wrapper;
84
+ margin-bottom: 0.75rem;
85
+ }
86
+
82
87
  &.collapsible {
83
88
  cursor: pointer;
84
89
 
85
- & + .sidebar-item-children {
86
- @include dropdown_wrapper;
87
- margin-bottom: 0.75rem;
90
+ .arrow {
91
+ position: relative;
92
+ top: -0.12em;
93
+ left: 0.5em;
88
94
  }
89
95
  }
90
-
91
- .arrow {
92
- position: relative;
93
- top: -0.12em;
94
- left: 0.5em;
95
- }
96
96
  }
97
97
 
98
98
  &:not(.sidebar-heading) {
@@ -128,9 +128,9 @@ export interface DefaultThemeLocaleData extends LocaleData {
128
128
  * - ...
129
129
  *
130
130
  * The max value depends on which headers you have extracted
131
- * via `markdown.extractHeaders.level`.
131
+ * via `markdown.headers.level`.
132
132
  *
133
- * The default value of `markdown.extractHeaders.level` is `[2, 3]`,
133
+ * The default value of `markdown.headers.level` is `[2, 3]`,
134
134
  * so the default max value of `sidebarDepth` is `2`
135
135
  */
136
136
  sidebarDepth?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.48",
3
+ "version": "2.0.0-beta.49",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -25,24 +25,24 @@
25
25
  "templates"
26
26
  ],
27
27
  "dependencies": {
28
- "@vuepress/client": "2.0.0-beta.48",
29
- "@vuepress/core": "2.0.0-beta.48",
30
- "@vuepress/plugin-active-header-links": "2.0.0-beta.48",
31
- "@vuepress/plugin-back-to-top": "2.0.0-beta.48",
32
- "@vuepress/plugin-container": "2.0.0-beta.48",
33
- "@vuepress/plugin-external-link-icon": "2.0.0-beta.48",
34
- "@vuepress/plugin-git": "2.0.0-beta.48",
35
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.48",
36
- "@vuepress/plugin-nprogress": "2.0.0-beta.48",
37
- "@vuepress/plugin-palette": "2.0.0-beta.48",
38
- "@vuepress/plugin-prismjs": "2.0.0-beta.48",
39
- "@vuepress/plugin-theme-data": "2.0.0-beta.48",
40
- "@vuepress/shared": "2.0.0-beta.48",
41
- "@vuepress/utils": "2.0.0-beta.48",
42
- "@vueuse/core": "^8.5.0",
43
- "sass": "^1.52.1",
44
- "vue": "^3.2.36",
45
- "vue-router": "^4.0.15"
28
+ "@vuepress/client": "2.0.0-beta.49",
29
+ "@vuepress/core": "2.0.0-beta.49",
30
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.49",
31
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.49",
32
+ "@vuepress/plugin-container": "2.0.0-beta.49",
33
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.49",
34
+ "@vuepress/plugin-git": "2.0.0-beta.49",
35
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.49",
36
+ "@vuepress/plugin-nprogress": "2.0.0-beta.49",
37
+ "@vuepress/plugin-palette": "2.0.0-beta.49",
38
+ "@vuepress/plugin-prismjs": "2.0.0-beta.49",
39
+ "@vuepress/plugin-theme-data": "2.0.0-beta.49",
40
+ "@vuepress/shared": "2.0.0-beta.49",
41
+ "@vuepress/utils": "2.0.0-beta.49",
42
+ "@vueuse/core": "^8.7.5",
43
+ "sass": "^1.53.0",
44
+ "vue": "^3.2.37",
45
+ "vue-router": "^4.1.2"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "sass-loader": "^13.0.0"