diff --git a/theme/src/client/components/Sidebar.vue b/theme/src/client/components/Sidebar.vue index 37dbe1a4..bee593a0 100644 --- a/theme/src/client/components/Sidebar.vue +++ b/theme/src/client/components/Sidebar.vue @@ -4,12 +4,13 @@ import { ref, watch } from 'vue' import { useSidebar } from '../composables/sidebar.js' import { inBrowser } from '../utils/index.js' import SidebarItem from './SidebarItem.vue' +import TransitionFadeSlideY from './TransitionFadeSlideY.vue' const props = defineProps<{ open: boolean }>() -const { sidebarGroups, hasSidebar } = useSidebar() +const { sidebarGroups, hasSidebar, sidebarKey } = useSidebar() // a11y: focus Nav element when menu has opened const navEl = ref(null) @@ -39,20 +40,23 @@ watch( >
- + diff --git a/theme/src/client/composables/sidebar.ts b/theme/src/client/composables/sidebar.ts index 7d5f18f8..c6dcf26e 100644 --- a/theme/src/client/composables/sidebar.ts +++ b/theme/src/client/composables/sidebar.ts @@ -47,6 +47,13 @@ export function useSidebar() { const isOpen = ref(false) + const sidebarKey = computed(() => { + const link = Object.keys(notesData.value).find(link => + route.path.startsWith(normalizePath(withBase(link))), + ) + return link + }) + const sidebar = computed(() => { return theme.value.notes ? getSidebarList(route.path, notesData.value) : [] }) @@ -88,6 +95,7 @@ export function useSidebar() { hasAside, isSidebarEnabled, sidebarGroups, + sidebarKey, open, close, toggle,