Skip to content

Commit

Permalink
feat(theme): allow disabling whole layout (#1268)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Sep 1, 2022
1 parent ecf5515 commit 8f63033
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/guide/theme-layout.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
layout: doc
---

# Layout

You may choose the page layout by setting `layout` option to the page [frontmatter](./frontmatter). There are 3 layout options, `doc`, `page`, and `home`. If nothing is specified, then the page is treated as `doc` page.
Expand Down Expand Up @@ -36,3 +32,7 @@ Note that even in this layout, sidebar will still show up if the page has a matc
## Home Layout

Option `home` will generate templated "Homepage". In this layout, you can set extra options such as `hero` and `features` to customize the content further. Please visit [Theme: Home Page](./theme-home-page) for more details.

## No Layout

If you don't want any layout, you can pass `layout: false` through frontmatter. This option is helpful if you want a fully-customizable landing page (without any sidebar, navbar, or footer by default).
7 changes: 5 additions & 2 deletions src/client/theme-default/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { provide, watch } from 'vue'
import { useRoute } from 'vitepress'
import { useData, useRoute } from 'vitepress'
import { useSidebar, useCloseSidebarOnEscape } from './composables/sidebar.js'
import VPSkipLink from './components/VPSkipLink.vue'
import VPBackdrop from './components/VPBackdrop.vue'
Expand All @@ -22,10 +22,12 @@ watch(() => route.path, closeSidebar)
useCloseSidebarOnEscape(isSidebarOpen, closeSidebar)
provide('close-sidebar', closeSidebar)
const { frontmatter } = useData()
</script>

<template>
<div class="Layout">
<div v-if="frontmatter.layout !== false" class="Layout">
<slot name="layout-top" />
<VPSkipLink />
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
Expand Down Expand Up @@ -61,6 +63,7 @@ provide('close-sidebar', closeSidebar)
<VPFooter />
<slot name="layout-bottom" />
</div>
<Content v-else />
</template>

<style scoped>
Expand Down

0 comments on commit 8f63033

Please sign in to comment.