-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBreadCrumbs.vue
More file actions
50 lines (45 loc) · 1.11 KB
/
BreadCrumbs.vue
File metadata and controls
50 lines (45 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
<RouterLink
v-for="(parent, index) in displayedParents"
:key="index"
:to="{ path: parent.id ? `/note/${parent.id}` : '' }"
class="breadcrumb"
>
{{ parent.content ? getTitle(parent.content) : '...' }}
<Icon
v-if="index < displayedParents.length - 1"
name="ChevronRight"
/>
</RouterLink>
</template>
<script setup lang="ts">
import { getTitle } from '@/infrastructure/utils/note.ts';
import { RouterLink } from 'vue-router';
import { computed } from 'vue';
import { Note } from '@/domain/entities/Note.ts';
import { Icon } from '@codexteam/ui/vue';
const props = defineProps<{
noteParents: Note[];
}>();
/**
* Note parents hierarchy
* If there are more than 3, only the closest & the furthest ones are shown
*/
const displayedParents = computed(() => {
if (props.noteParents.length > 3) {
return [
props.noteParents[0],
{ id: '',
content: null },
props.noteParents[props.noteParents.length - 1],
];
}
return props.noteParents;
});
</script>
<style scoped>
.breadcrumb {
display: inline-flex;
align-items: center;
}
</style>