Skip to content

Commit 0ab43a7

Browse files
feat(breadcrumbs): move parent content handle to computed
1 parent 3487637 commit 0ab43a7

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/presentation/components/breadcrumbs/BreadCrumbs.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
:to="`/note/${parent.id}`"
66
class="breadcrumb"
77
>
8-
{{ parent.content ?
9-
typeof parent.content === 'string' ?
10-
parent.content :
11-
getTitle(parent.content) : '...' }}
8+
{{ parentTitle(parent.content) }}
129
<Icon
1310
v-if="index < displayedParents.length - 1"
1411
name="ChevronRight"
@@ -23,6 +20,7 @@ import { RouterLink } from 'vue-router';
2320
import { computed } from 'vue';
2421
import { Note } from '@/domain/entities/Note.ts';
2522
import { Icon } from '@codexteam/ui/vue';
23+
import { OutputData } from '@editorjs/editorjs';
2624
2725
const props = defineProps<{
2826
noteParents: (Note | { id: string; content: string })[];
@@ -43,6 +41,24 @@ const displayedParents = computed(() => {
4341
4442
return props.noteParents;
4543
});
44+
45+
/**
46+
* title of the parent
47+
*
48+
* @param content - parent's content, could be
49+
*/
50+
const parentTitle = computed(() => {
51+
return (content: string | null | OutputData) => {
52+
if (content === null) {
53+
return '...';
54+
}
55+
if (typeof content === 'string') {
56+
return content;
57+
}
58+
59+
return getTitle(content);
60+
};
61+
});
4662
</script>
4763

4864
<style scoped>

0 commit comments

Comments
 (0)