2023-07-16 13:18:07 +02:00
|
|
|
<template>
|
|
|
|
<ul class="toc-links mb-4 space-y-2">
|
|
|
|
<li
|
2023-07-18 11:14:54 +02:00
|
|
|
v-for="link in findDeepObject((links[0] as NavItem), (v) => realBasePath.replace(/\/$/, '') === v?._path.replace(/\/$/, ''))?.children ?? []"
|
2023-07-16 13:18:07 +02:00
|
|
|
:key="link.text"
|
|
|
|
:class="[`depth-${link.depth}`]"
|
|
|
|
>
|
2023-07-18 11:14:54 +02:00
|
|
|
<GNuxtLink
|
|
|
|
:to="link._path"
|
|
|
|
@click.passive="emit('child-click');"
|
|
|
|
:class="['hover:text-accent-600']"
|
2023-07-16 13:18:07 +02:00
|
|
|
>
|
|
|
|
{{ link.text }}
|
2023-07-18 11:14:54 +02:00
|
|
|
</GNuxtLink>
|
2023-07-16 13:18:07 +02:00
|
|
|
<AsideNav
|
|
|
|
class="mt-2"
|
|
|
|
v-if="link.children"
|
|
|
|
:links="link.children"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import type { PropType } from 'vue'
|
2023-07-18 11:14:54 +02:00
|
|
|
import type { NavItem } from '@nuxt/content/dist/runtime/types'
|
|
|
|
import { findDeepObject } from 'assets/js/misc';
|
2023-07-16 13:18:07 +02:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
links: {
|
2023-07-18 11:14:54 +02:00
|
|
|
type: Array as PropType<NavItem[]>,
|
2023-07-16 13:18:07 +02:00
|
|
|
default: () => []
|
2023-07-18 11:14:54 +02:00
|
|
|
},
|
|
|
|
basePath: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2023-07-16 13:18:07 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-07-18 11:14:54 +02:00
|
|
|
const { locale } = useI18n();
|
|
|
|
const route = useRoute();
|
2023-07-16 13:18:07 +02:00
|
|
|
|
2023-07-18 11:14:54 +02:00
|
|
|
const realBasePath = computed<string>(() => {
|
|
|
|
if (props.basePath) {
|
|
|
|
return props.basePath;
|
2023-07-16 13:18:07 +02:00
|
|
|
}
|
2023-07-18 11:14:54 +02:00
|
|
|
return route.path.replace(/^.*\/docs/, `/${locale.value}/docs`);
|
|
|
|
});
|
|
|
|
|
|
|
|
const emit = defineEmits(['move', 'child-click']);
|
2023-07-16 13:18:07 +02:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.toc-links ::v-deep(.depth-3) {
|
|
|
|
@apply ml-2;
|
|
|
|
}
|
|
|
|
.toc-links ::v-deep(.depth-4) {
|
|
|
|
@apply ml-4;
|
|
|
|
}
|
|
|
|
</style>
|