✨ (title) use title notes for HTML title
This commit is contained in:
@@ -6,6 +6,7 @@ import { useOverlay } from '@/hooks/useOverlay.hook'
|
||||
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { pathToNoteTitle } from '@/utils/noteTitle'
|
||||
|
||||
export const useNote = (containerClass: string) => {
|
||||
const store = useUserRepoStore()
|
||||
@@ -19,15 +20,7 @@ export const useNote = (containerClass: string) => {
|
||||
}
|
||||
const filePath = store.files.find((file) => file.sha === note)?.path ?? ''
|
||||
|
||||
const fileNames = filePath.split('.')
|
||||
|
||||
fileNames.pop()
|
||||
obj[note] = fileNames
|
||||
.join('.')
|
||||
.split('/')
|
||||
.filter((path) => !path.includes('README'))
|
||||
.join('/')
|
||||
.replaceAll('-', ' ')
|
||||
obj[note] = pathToNoteTitle(filePath)
|
||||
|
||||
return obj
|
||||
}, {})
|
||||
|
||||
23
src/hooks/useTitleNotes.hook.ts
Normal file
23
src/hooks/useTitleNotes.hook.ts
Normal 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])
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user