-
-
Notifications
You must be signed in to change notification settings - Fork 605
/
NavItem.vue
53 lines (49 loc) · 1.12 KB
/
NavItem.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script setup lang="ts">
import { computed } from 'vue'
import type { NavItem } from '../../../src/runtime/types'
const props = defineProps<{
navItem: NavItem
}>()
const icon = computed(() => {
if (props.navItem.icon) { return props.navItem.icon }
if (props.navItem.children && props.navItem.children.length) { return '📁' }
return '📄'
})
</script>
<template>
<li>
<div v-if="navItem.children && navItem.children.length">
<span>{{ icon }}</span> <span class="title">{{ navItem.title }}</span>
</div>
<NuxtLink v-else :to="navItem._path">
<span>{{ icon }}</span> <span class="title">{{ navItem.title }}</span>
</NuxtLink>
<ul v-if="navItem.children">
<NavItem v-for="item of navItem.children" :key="item._path" :nav-item="item" />
</ul>
</li>
</template>
<style scoped>
ul {
margin: 0;
padding-left: 20px;
}
li {
list-style-type: none;
padding: 0.15rem 0.5rem;
}
a {
text-decoration: none;
}
.title {
display: inline-block;
margin-left: 4px;
font-family: sans-serif;
}
a .title {
text-decoration: underline;
}
.router-link-exact-active {
font-weight: bold;
}
</style>