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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow disabling whole layout #1268

Merged
merged 1 commit into from
Sep 1, 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
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