Skip to content

Commit 873f1f1

Browse files
authored
Merge pull request #88 from wilfredinni/next
chore: init toc only on xl and larger screens
2 parents 466f752 + 80f86c8 commit 873f1f1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/components/layout/TheToc.vue

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<script setup lang="ts">
2+
import { breakpointsTailwind } from '@vueuse/core'
23
import type { Ref } from 'vue'
34
5+
const breakpoints = useBreakpoints(breakpointsTailwind)
6+
const xlAndLarger = breakpoints.greater('xl')
7+
48
interface Toc {
59
header: string
610
id: string
@@ -34,16 +38,21 @@ const getObserver = () => {
3438
})
3539
}
3640
41+
const initToc = () => {
42+
if (xlAndLarger.value) {
43+
createToc()
44+
getObserver()
45+
}
46+
}
47+
3748
const route = useRoute()
3849
onMounted(() => {
39-
createToc()
40-
getObserver()
50+
initToc()
4151
})
4252
4353
watch(route, () => {
4454
nextTick(() => {
45-
createToc()
46-
getObserver()
55+
initToc()
4756
})
4857
})
4958
</script>

0 commit comments

Comments
 (0)