|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
</SideBar>
|
|
|
|
|
</aside>
|
|
|
|
|
<!-- TODO: make this button accessible -->
|
|
|
|
|
<div
|
|
|
|
|
class="sidebar-mask"
|
|
|
|
|
:class="{ 'sidebar-open': open }"
|
|
|
|
@ -38,11 +39,12 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { ref, watch } from 'vue'
|
|
|
|
|
import NavBar from './components/NavBar.vue'
|
|
|
|
|
import ToggleSideBarButton from './components/ToggleSideBarButton.vue'
|
|
|
|
|
import SideBar from './components/SideBar.vue'
|
|
|
|
|
import Page from './components/Page.vue'
|
|
|
|
|
import { useRoute } from 'vitepress'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
@ -54,11 +56,18 @@ export default {
|
|
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
|
const open = ref(false)
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
const toggleSidebar = (to) => {
|
|
|
|
|
open.value = typeof to === 'boolean' ? to : !open.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hideSidebar = toggleSidebar.bind(null, false)
|
|
|
|
|
// close the sidebar when navigating to a different location
|
|
|
|
|
watch(route, hideSidebar)
|
|
|
|
|
// TODO: route only changes when the pathname changes
|
|
|
|
|
// listening to hashchange does nothing because it's prevented in router
|
|
|
|
|
|
|
|
|
|
return { open, toggleSidebar }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|