Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme) sidebar nav slots #1582

Merged
merged 2 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/guide/theme-introduction.md
Expand Up @@ -201,6 +201,8 @@ Full list of slots available in the default theme layout:
- `doc-footer-before`
- `doc-before`
- `doc-after`
- `sidebar-nav-before`
- `sidebar-nav-after`
- `aside-top`
- `aside-bottom`
- `aside-outline-before`
Expand Down
6 changes: 5 additions & 1 deletion src/client/theme-default/Layout.vue
Expand Up @@ -40,7 +40,11 @@ const { frontmatter } = useData()
<template #nav-screen-content-after><slot name="nav-screen-content-after" /></template>
</VPNav>
<VPLocalNav :open="isSidebarOpen" @open-menu="openSidebar" />
<VPSidebar :open="isSidebarOpen" />

<VPSidebar :open="isSidebarOpen">
<template #sidebar-nav-before><slot name="sidebar-nav-before" /></template>
<template #sidebar-nav-after><slot name="sidebar-nav-after" /></template>
</VPSidebar>

<VPContent>
<template #home-hero-before><slot name="home-hero-before" /></template>
Expand Down
4 changes: 4 additions & 0 deletions src/client/theme-default/components/VPSidebar.vue
Expand Up @@ -44,6 +44,8 @@ watchPostEffect(async () => {
Sidebar Navigation
</span>

<slot name="sidebar-nav-before" />

<div v-for="group in sidebar" :key="group.text" class="group">
<VPSidebarGroup
:text="group.text"
Expand All @@ -52,6 +54,8 @@ watchPostEffect(async () => {
:collapsed="group.collapsed"
/>
</div>

<slot name="sidebar-nav-after" />
</nav>
</aside>
</template>
Expand Down