You've already forked obsidian-visualiser
New useContent composable to store global navigation state. Fixes for Markdown and Canvas
This commit is contained in:
@@ -89,10 +89,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Icon } from '@iconify/vue/dist/iconify.js';
|
||||
import type { NavigationTreeItem } from '~/server/api/navigation.get';
|
||||
import { iconByType } from '#shared/general.utils';
|
||||
import type { DropdownOption } from '~/components/base/DropdownMenu.vue';
|
||||
import { hasPermissions } from '~/shared/auth.util';
|
||||
import type { TreeItem } from '~/types/content';
|
||||
|
||||
const options = ref<DropdownOption[]>([{
|
||||
type: 'item',
|
||||
@@ -114,13 +114,10 @@ watch(route, () => {
|
||||
open.value = false;
|
||||
});
|
||||
|
||||
const { data: pages } = await useLazyFetch('/api/navigation', {
|
||||
transform: transform,
|
||||
watch: [useRouter().currentRoute]
|
||||
});
|
||||
|
||||
function transform(list: NavigationTreeItem[] | undefined): NavigationTreeItem[] | undefined
|
||||
const { tree } = useContent();
|
||||
const pages = computed(() => transform(tree.value));
|
||||
function transform(list: TreeItem[] | undefined): TreeItem[] | undefined
|
||||
{
|
||||
return list?.map(e => ({ ...e, open: path.value?.startsWith(e.path), children: transform(e.children) }));
|
||||
return list?.filter(e => e.navigable)?.map(e => ({ ...e, open: path.value?.startsWith(e.path), children: transform(e.children) }));
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user