kjdskjdks
This commit is contained in:
@@ -4,8 +4,13 @@ import { useTreeState } from '~/composables/useTreeState'
|
|||||||
defineProps({ nodes: Array, depth: { type: Number, default: 0 } })
|
defineProps({ nodes: Array, depth: { type: Number, default: 0 } })
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
const { collapsed } = useTreeState()
|
const { collapsed } = useTreeState()
|
||||||
|
|
||||||
|
function isActive(path) {
|
||||||
|
return !!path && route.path === path
|
||||||
|
}
|
||||||
|
|
||||||
function getTitle(node) {
|
function getTitle(node) {
|
||||||
if (node.title === 'index') return 'Index'
|
if (node.title === 'index') return 'Index'
|
||||||
return node.title || node._path?.split('/').pop() || 'Home'
|
return node.title || node._path?.split('/').pop() || 'Home'
|
||||||
@@ -51,7 +56,12 @@ function visibleChildren(node) {
|
|||||||
|
|
||||||
<!-- Leaf node (no children) -->
|
<!-- Leaf node (no children) -->
|
||||||
<template v-if="!node.children?.length">
|
<template v-if="!node.children?.length">
|
||||||
<a v-if="node.path" :href="node.path" @click.prevent="navigate(node.path)">
|
<a
|
||||||
|
v-if="node.path"
|
||||||
|
:href="node.path"
|
||||||
|
:class="{ active: isActive(node.path) }"
|
||||||
|
@click.prevent="navigate(node.path)"
|
||||||
|
>
|
||||||
{{ getTitle(node) }}
|
{{ getTitle(node) }}
|
||||||
</a>
|
</a>
|
||||||
<span v-else>{{ getTitle(node) }}</span>
|
<span v-else>{{ getTitle(node) }}</span>
|
||||||
@@ -73,6 +83,7 @@ function visibleChildren(node) {
|
|||||||
<a
|
<a
|
||||||
v-if="getSelfTitledChild(node)"
|
v-if="getSelfTitledChild(node)"
|
||||||
class="folder-label folder-label--link"
|
class="folder-label folder-label--link"
|
||||||
|
:class="{ active: isActive(getSelfTitledChild(node).path) }"
|
||||||
:href="getSelfTitledChild(node).path"
|
:href="getSelfTitledChild(node).path"
|
||||||
@click.prevent="navigate(getSelfTitledChild(node).path)"
|
@click.prevent="navigate(getSelfTitledChild(node).path)"
|
||||||
>
|
>
|
||||||
@@ -104,6 +115,12 @@ li {
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--text-link);
|
color: var(--text-link);
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: var(--text-primary, currentColor);
|
||||||
|
font-weight: 600;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-row {
|
.folder-row {
|
||||||
|
|||||||
Reference in New Issue
Block a user