NavigationGroup.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <li class="relative mt-6" v-if="group._path != '/docs'">
  3. <h2 class="text-xs font-semibold text-white">
  4. {{ group.title }}
  5. </h2>
  6. <div class="relative mt-3 pl-2">
  7. <div class="absolute inset-y-0 left-2 w-px bg-white/5"></div>
  8. <ul role="list" class="border-l border-white/20">
  9. <li v-for="link in group.children"
  10. :key="link.href"
  11. :class="{
  12. 'rounded-lg bg-white/5 -ml-4 pl-4': link._path === route.path
  13. }">
  14. <NuxtLink
  15. :to="link._path"
  16. class="flex justify-between gap-2 py-1 pr-3 text-sm transition"
  17. :class="{
  18. 'text-white': link._path === route.path,
  19. 'text-zinc-400 hover:text-white': link._path != route.path
  20. }">
  21. <span class="pl-4 truncate"
  22. :class="{
  23. '-ml-[1px] border-l border-blue-500': link._path === route.path
  24. }">{{ link.title }}</span>
  25. </NuxtLink>
  26. <ul v-if="link._path == route.path">
  27. <li v-for="( link, linkIndex ) in toc.links"
  28. :key="'link-'+linkIndex">
  29. <NuxtLink
  30. @click="scrollTo('#'+link.id)"
  31. :to="'#'+link.id"
  32. class="flex justify-between gap-2 py-1 pr-3 text-sm transition pl-7 text-zinc-400 hover:text-white">
  33. <span class="truncate">{{ link.text }}</span>
  34. <!-- <DocsTag v-if="link.tag == 'app-heading-2' && link.props.tag != ''" :variant="'small'" :color="'zinc'">
  35. {{ link.props.tag }}
  36. </DocsTag> -->
  37. </NuxtLink>
  38. </li>
  39. </ul>
  40. </li>
  41. </ul>
  42. </div>
  43. </li>
  44. </template>
  45. <script setup>
  46. const props = defineProps(['group', 'toc']);
  47. const route = useRoute();
  48. const scrollTo = (id) => {
  49. document.getElementById( id.replace('#', '') ).scrollIntoView(true, {behavior: "smooth"})
  50. }
  51. </script>