Skip to content

Commit a42e431

Browse files
committed
feat(theme-default): support navbar and sidebar slot for Layout.vue
1 parent 90b2b6a commit a42e431

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

docs/advanced/cookbook/extending-a-theme.md

+2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ You will add a custom footer to every normal pages in default theme (excluding h
126126

127127
Here are all the slots that provided by the `Layout` of default theme:
128128

129+
- `navbar`
129130
- `navbar-before`
130131
- `navbar-after`
132+
- `sidebar`
131133
- `sidebar-top`
132134
- `sidebar-bottom`
133135
- `page`

docs/zh/advanced/cookbook/extending-a-theme.md

+2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ export default {
126126

127127
下面列出了默认主题的 `Layout` 所提供的所有插槽:
128128

129+
- `navbar`
129130
- `navbar-before`
130131
- `navbar-after`
132+
- `sidebar`
131133
- `sidebar-top`
132134
- `sidebar-bottom`
133135
- `page`

packages/@vuepress/theme-default/src/client/layouts/Layout.vue

+20-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@
55
@touchstart="onTouchStart"
66
@touchend="onTouchEnd"
77
>
8-
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
9-
<template #before>
10-
<slot name="navbar-before" />
11-
</template>
12-
<template #after>
13-
<slot name="navbar-after" />
14-
</template>
15-
</Navbar>
8+
<slot name="navbar">
9+
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
10+
<template #before>
11+
<slot name="navbar-before" />
12+
</template>
13+
<template #after>
14+
<slot name="navbar-after" />
15+
</template>
16+
</Navbar>
17+
</slot>
1618

1719
<div class="sidebar-mask" @click="toggleSidebar(false)" />
1820

19-
<Sidebar>
20-
<template #top>
21-
<slot name="sidebar-top" />
22-
</template>
23-
<template #bottom>
24-
<slot name="sidebar-bottom" />
25-
</template>
26-
</Sidebar>
21+
<slot name="sidebar">
22+
<Sidebar>
23+
<template #top>
24+
<slot name="sidebar-top" />
25+
</template>
26+
<template #bottom>
27+
<slot name="sidebar-bottom" />
28+
</template>
29+
</Sidebar>
30+
</slot>
2731

2832
<slot name="page">
2933
<Home v-if="frontmatter.home" />

0 commit comments

Comments
 (0)