(title) use title notes for HTML title

This commit is contained in:
2021-08-08 12:36:37 +02:00
parent 496c161266
commit 8f46bd4740
4 changed files with 39 additions and 9 deletions

View File

@@ -0,0 +1,23 @@
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
import { useNotes } from '@/modules/note/hooks/useNotes'
import { pathToNoteTitle } from '@/utils/noteTitle'
import { useTitle } from '@vueuse/core'
import { computed, watch } from 'vue'
export const generateTitle = (titles: string[]) => titles.join(' | ')
export const useTitleNotes = (prefix: string) => {
const { stackedNotes } = useQueryStackedNotes()
const { notes } = useNotes()
const titleNotes = computed(() =>
notes.value
.filter((note) => stackedNotes.value.includes(note.sha ?? ''))
.map((note) => pathToNoteTitle(note.path ?? ''))
)
const title = useTitle(generateTitle([prefix, ...titleNotes.value]))
watch(titleNotes, () => {
title.value = generateTitle([prefix, ...titleNotes.value])
})
}