Files
heroui-vue/apps/docs/.vitepress/theme/DocsToc.vue
T

34 lines
993 B
Vue

<script setup lang="ts">
import { Link } from "@heroui-vue/components";
interface TocEntry {
title: string;
slug: string;
children?: TocEntry[];
}
defineProps<{ headers: TocEntry[]; active: string }>();
const emit = defineEmits<{ navigate: [slug: string, event: MouseEvent] }>();
</script>
<template>
<nav class="toc-links" aria-label="本页目录">
<template v-for="heading in headers" :key="heading.slug">
<Link
:href="'#' + heading.slug"
:aria-current="active === heading.slug ? 'location' : undefined"
@click="emit('navigate', heading.slug, $event)"
>
{{ heading.title }}
</Link>
<Link
v-for="child in heading.children"
:key="child.slug"
class="nested"
:href="'#' + child.slug"
:aria-current="active === child.slug ? 'location' : undefined"
@click="emit('navigate', child.slug, $event)"
>
{{ child.title }}
</Link>
</template>
</nav>
</template>