|
16 | 16 | </svg> |
17 | 17 | </button> |
18 | 18 |
|
19 | | - <nuxt-link |
| 19 | + <NuxtLink |
20 | 20 | to="/" |
21 | 21 | class="text-lg font-semibold tracking-widest text-gray-900 uppercase rounded-lg dark-mode:text-white focus:outline-none focus:shadow-outline" |
22 | | - >BasicBrogrammer</nuxt-link |
| 22 | + >BasicBrogrammer</NuxtLink |
23 | 23 | > |
24 | 24 | </div> |
25 | 25 | <div class="main-body"> |
26 | | - <transition name="sidebar-slide"> |
| 26 | + <Transition name="sidebar-slide"> |
27 | 27 | <SideBar v-if="showSideBar" /> |
28 | | - </transition> |
| 28 | + </Transition> |
29 | 29 | <article class="w-screen p-4 md:w-3/4"> |
30 | 30 | <div class="mx-auto w-full md:w-3/4"> |
31 | | - <Nuxt /> |
| 31 | + <slot /> |
32 | 32 | </div> |
33 | 33 | </article> |
34 | 34 | </div> |
35 | 35 | </main> |
36 | 36 | </template> |
37 | | -<script> |
38 | | -import SideBar from '@/components/SideBar' |
39 | 37 |
|
40 | | -export default { |
41 | | - components: { SideBar }, |
42 | | - data() { |
43 | | - return { |
44 | | - sideNavOpen: false, |
45 | | - windowWidth: window.innerWidth, |
46 | | - } |
47 | | - }, |
48 | | - computed: { |
49 | | - showSideBar() { |
50 | | - return this.windowWidth > 767 || this.sideNavOpen |
51 | | - }, |
52 | | - sidebarToggleIcon() { |
53 | | - return this.sideNavOpen |
54 | | - ? 'M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z' |
55 | | - : 'M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z' |
56 | | - }, |
57 | | - }, |
58 | | - watch: { |
59 | | - $route() { |
60 | | - this.sideNavOpen = false |
61 | | - }, |
62 | | - }, |
63 | | - mounted() { |
| 38 | +<script setup> |
| 39 | +const route = useRoute() |
| 40 | +const sideNavOpen = ref(false) |
| 41 | +const windowWidth = ref(768) |
| 42 | +
|
| 43 | +const showSideBar = computed(() => { |
| 44 | + return windowWidth.value > 767 || sideNavOpen.value |
| 45 | +}) |
| 46 | +
|
| 47 | +const sidebarToggleIcon = computed(() => { |
| 48 | + return sideNavOpen.value |
| 49 | + ? 'M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z' |
| 50 | + : 'M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z' |
| 51 | +}) |
| 52 | +
|
| 53 | +watch(() => route.path, () => { |
| 54 | + sideNavOpen.value = false |
| 55 | +}) |
| 56 | +
|
| 57 | +onMounted(() => { |
| 58 | + if (process.client) { |
| 59 | + windowWidth.value = window.innerWidth |
64 | 60 | window.addEventListener('resize', () => { |
65 | | - this.windowWidth = window.innerWidth |
| 61 | + windowWidth.value = window.innerWidth |
66 | 62 | }) |
67 | | - }, |
68 | | -} |
| 63 | + } |
| 64 | +}) |
69 | 65 | </script> |
70 | 66 |
|
71 | 67 | <style> |
|
0 commit comments