diff --git a/src/client/theme-default/Layout.vue b/src/client/theme-default/Layout.vue
index 7af05e9d..5087ee46 100644
--- a/src/client/theme-default/Layout.vue
+++ b/src/client/theme-default/Layout.vue
@@ -1,5 +1,6 @@
diff --git a/src/client/theme-default/composables/nav.ts b/src/client/theme-default/composables/nav.ts
index 4d24c01c..e3cf686b 100644
--- a/src/client/theme-default/composables/nav.ts
+++ b/src/client/theme-default/composables/nav.ts
@@ -1,5 +1,5 @@
import type { DefaultTheme } from 'vitepress/theme'
-import { ref, computed } from 'vue'
+import { ref, computed, watch } from 'vue'
import { useData, useRoute } from 'vitepress'
export function useNav() {
@@ -26,6 +26,9 @@ export function useNav() {
window.outerWidth >= 768 && closeScreen()
}
+ const route = useRoute()
+ watch(() => route.path, closeScreen)
+
return {
isScreenOpen,
openScreen,
diff --git a/src/client/theme-default/composables/sidebar.ts b/src/client/theme-default/composables/sidebar.ts
index 40f725c8..7baedde4 100644
--- a/src/client/theme-default/composables/sidebar.ts
+++ b/src/client/theme-default/composables/sidebar.ts
@@ -1,5 +1,5 @@
-import { Ref, ref, computed, watchEffect, onMounted, onUnmounted } from 'vue'
-import { useRoute, useData } from 'vitepress'
+import { computed, onMounted, onUnmounted, Ref, ref, watchEffect } from 'vue'
+import { useData, useRoute } from 'vitepress'
import { getSidebar } from '../support/sidebar'
export function useSidebar() {
@@ -10,9 +10,7 @@ export function useSidebar() {
const sidebar = computed(() => {
const sidebarConfig = theme.value.sidebar
- const relativePath = route.data.relativePath
-
- return sidebarConfig ? getSidebar(sidebarConfig, relativePath) : []
+ return sidebarConfig ? getSidebar(sidebarConfig, route.path) : []
})
const hasSidebar = computed(() => {