Skip to content

Commit 8f63033

Browse files
authored
feat(theme): allow disabling whole layout (#1268)
1 parent ecf5515 commit 8f63033

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/guide/theme-layout.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
layout: doc
3-
---
4-
51
# Layout
62

73
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.
@@ -36,3 +32,7 @@ Note that even in this layout, sidebar will still show up if the page has a matc
3632
## Home Layout
3733

3834
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.
35+
36+
## No Layout
37+
38+
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).

src/client/theme-default/Layout.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { provide, watch } from 'vue'
3-
import { useRoute } from 'vitepress'
3+
import { useData, useRoute } from 'vitepress'
44
import { useSidebar, useCloseSidebarOnEscape } from './composables/sidebar.js'
55
import VPSkipLink from './components/VPSkipLink.vue'
66
import VPBackdrop from './components/VPBackdrop.vue'
@@ -22,10 +22,12 @@ watch(() => route.path, closeSidebar)
2222
useCloseSidebarOnEscape(isSidebarOpen, closeSidebar)
2323
2424
provide('close-sidebar', closeSidebar)
25+
26+
const { frontmatter } = useData()
2527
</script>
2628

2729
<template>
28-
<div class="Layout">
30+
<div v-if="frontmatter.layout !== false" class="Layout">
2931
<slot name="layout-top" />
3032
<VPSkipLink />
3133
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
@@ -61,6 +63,7 @@ provide('close-sidebar', closeSidebar)
6163
<VPFooter />
6264
<slot name="layout-bottom" />
6365
</div>
66+
<Content v-else />
6467
</template>
6568

6669
<style scoped>

0 commit comments

Comments
 (0)