diff --git a/src/hooks/useNote.hook.ts b/src/hooks/useNote.hook.ts index d29e3a3..e2a37fe 100644 --- a/src/hooks/useNote.hook.ts +++ b/src/hooks/useNote.hook.ts @@ -6,7 +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' +import { pathToNotePathTitle } from '@/utils/noteTitle' export const useNote = (containerClass: string) => { const store = useUserRepoStore() @@ -20,7 +20,7 @@ export const useNote = (containerClass: string) => { } const filePath = store.files.find((file) => file.sha === note)?.path ?? '' - obj[note] = pathToNoteTitle(filePath) + obj[note] = pathToNotePathTitle(filePath) return obj }, {}) diff --git a/src/utils/noteTitle.ts b/src/utils/noteTitle.ts index da0bd10..503322c 100644 --- a/src/utils/noteTitle.ts +++ b/src/utils/noteTitle.ts @@ -1,7 +1,7 @@ export const filenameToNoteTitle = (title: string) => title.replaceAll('/', ' / ').replaceAll('-', ' ') -export const pathToNoteTitle = (path: string) => { +export const pathToNotePathTitle = (path: string) => { const fileNames = path.split('.') fileNames.pop() @@ -12,3 +12,7 @@ export const pathToNoteTitle = (path: string) => { .join('/') .replaceAll('-', ' ') } + +export const pathToNoteTitle = (notePathTitle: string) => { + return pathToNotePathTitle(notePathTitle).split('/').pop()?.trim() ?? '' +}