Skip to content

Commit

Permalink
feat: expose layout slots for injecting custom content
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 23, 2018
1 parent ddb590d commit 3814e88
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
@touchend="onTouchEnd">
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar"/>
<div class="sidebar-mask" @click="toggleSidebar(false)"></div>
<Sidebar :items="sidebarItems" @toggle-sidebar="toggleSidebar"/>
<Sidebar :items="sidebarItems" @toggle-sidebar="toggleSidebar">
<slot name="sidebar-top" slot="top"/>
<slot name="sidebar-bottom" slot="bottom"/>
</Sidebar>
<div class="custom-layout" v-if="$page.frontmatter.layout">
<component :is="$page.frontmatter.layout"/>
</div>
<Home v-else-if="$page.frontmatter.home"/>
<Page v-else :sidebar-items="sidebarItems"/>
<Page v-else :sidebar-items="sidebarItems">
<slot name="page-top" slot="top"/>
<slot name="page-bottom" slot="bottom"/>
</Page>
</div>
</template>

Expand Down
1 change: 1 addition & 0 deletions lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</span>
</p>
</div>
<slot name="bottom"/>
</div>
</template>

Expand Down
2 changes: 2 additions & 0 deletions lib/default-theme/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="sidebar">
<NavLinks/>
<slot name="top"/>
<ul class="sidebar-links" v-if="items.length">
<li v-for="(item, i) in items">
<SidebarGroup v-if="item.type === 'group'"
Expand All @@ -12,6 +13,7 @@
<SidebarLink v-else :item="item"/>
</li>
</ul>
<slot name="bottom"/>
</div>
</template>

Expand Down
1 change: 1 addition & 0 deletions lib/webpack/createBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = function createBaseConfig ({
.set('@source', sourceDir)
.set('@app', path.resolve(__dirname, '../app'))
.set('@temp', path.resolve(__dirname, '../app/.temp'))
.set('@default-theme', path.resolve(__dirname, '../default-theme'))
.set('@AlgoliaSearchBox', isAlgoliaSearch
? path.resolve(__dirname, '../default-theme/AlgoliaSearchBox.vue')
: path.resolve(__dirname, '../noop.js'))
Expand Down

0 comments on commit 3814e88

Please sign in to comment.