audiobookshelf.audiobookshe.../layouts/docs.vue

72 lines
1.6 KiB
Vue
Raw Permalink Normal View History

2022-05-05 18:13:06 -05:00
<template>
<div class="w-screen h-screen max-w-full max-h-screen text-white bg-gradient overflow-hidden">
2024-01-07 12:43:15 -06:00
<single-page-side-nav :content="content" :is-mobile="isMobile" :is-open.sync="drawerOpen" />
2022-05-05 18:13:06 -05:00
<div id="docs-content" class="overflow-y-auto max-w-full overflow-x-hidden">
2024-01-07 12:43:15 -06:00
<div class="w-full max-w-5xl mx-auto px-2 py-8">
<header-page-header has-content :is-mobile="isMobile" @openDrawer="openDrawer" />
<Nuxt />
</div>
2022-05-05 18:13:06 -05:00
</div>
</div>
</template>
<script>
export default {
2022-12-24 11:04:20 -06:00
async fetch() {
this.content = await this.$content(this.$route.name, { deep: true }).fetch()
2023-02-28 17:15:43 -06:00
this.content.sort((a, b) => Number(a.order) - Number(b.order))
2022-12-24 11:04:20 -06:00
if (process.env.NODE_ENV === 'development') console.log('CONTENT', this.content)
},
2022-05-05 18:13:06 -05:00
data() {
return {
2024-01-07 12:43:15 -06:00
drawerOpen: false,
isMobile: false,
content: []
2022-12-24 11:04:20 -06:00
}
},
2022-05-05 18:13:06 -05:00
watch: {
2024-01-07 12:43:15 -06:00
$route(to, from) {
if (this.isMobile) {
this.drawerOpen = false
2022-05-05 18:13:06 -05:00
}
}
},
2024-01-07 12:43:15 -06:00
computed: {},
2022-05-05 18:13:06 -05:00
methods: {
2024-01-07 12:43:15 -06:00
openDrawer() {
this.drawerOpen = true
2022-05-05 18:13:06 -05:00
},
2024-01-07 12:43:15 -06:00
resize() {
2025-03-10 17:14:11 -05:00
this.isMobile = window.innerWidth < 767 || window.innerHeight < 767
2024-01-07 12:43:15 -06:00
this.drawerOpen = !this.isMobile
2022-05-05 18:13:06 -05:00
}
},
mounted() {
2024-01-07 12:43:15 -06:00
this.resize()
window.addEventListener('resize', this.resize)
2022-05-05 18:13:06 -05:00
},
beforeDestroy() {
2024-01-07 12:43:15 -06:00
window.removeEventListener('resize', this.resize)
2022-05-05 18:13:06 -05:00
}
}
</script>
<style>
:root {
2024-01-07 12:43:15 -06:00
--sidebar-width: 288px;
2022-05-05 18:13:06 -05:00
}
#docs-content {
margin-left: var(--sidebar-width);
height: 100vh;
}
@media (max-width: 767px) {
#docs-content {
margin-left: 0px;
height: 100vh;
}
}
2023-02-05 09:57:57 +05:30
</style>