Skip to content

Commit

Permalink
feat(theme): support hiding aside component from frontmatter (#980)
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
userquin and brc-dd authored Jul 14, 2022
1 parent e4c60ab commit 69ef299
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
13 changes: 13 additions & 0 deletions docs/config/frontmatter-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,16 @@ interface Feature {
details: string
}
```

## aside

- Type: `boolean`
- Default: `true`

If you want the right aside component in `doc` layout not to be shown, set this option to `false`.

```yaml
---
aside: false
---
```
12 changes: 9 additions & 3 deletions src/client/theme-default/components/VPDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import VPDocAside from './VPDocAside.vue'
import VPDocFooter from './VPDocFooter.vue'
const route = useRoute()
const { hasSidebar } = useSidebar()
const { hasSidebar, hasAside } = useSidebar()
const pageName = computed(() =>
route.path.replace(/[./]+/g, '_').replace(/_html$/, '')
)
</script>

<template>
<div class="VPDoc" :class="{ 'has-sidebar': hasSidebar }">
<div
class="VPDoc"
:class="{ 'has-sidebar': hasSidebar, 'has-aside': hasAside }"
>
<div class="container">
<div class="aside">
<div v-if="hasAside" class="aside">
<div class="aside-curtain" />
<div class="aside-container">
<div class="aside-content">
Expand Down Expand Up @@ -170,6 +173,9 @@ const pageName = computed(() =>
.content-container {
margin: 0 auto;
}
.VPDoc.has-aside .content-container {
max-width: 688px;
}
</style>
11 changes: 11 additions & 0 deletions src/client/theme-default/composables/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export function useSidebar() {
)
})

const hasAside = computed(() => {
if (
frontmatter.value.layout !== 'home' &&
frontmatter.value.aside === false
)
return false

return hasSidebar.value
})

function open() {
isOpen.value = true
}
Expand All @@ -38,6 +48,7 @@ export function useSidebar() {
isOpen,
sidebar,
hasSidebar,
hasAside,
open,
close,
toggle
Expand Down

0 comments on commit 69ef299

Please sign in to comment.