Files
remanso/src/utils/noteTitle.ts
2021-08-09 20:13:04 +02:00

19 lines
496 B
TypeScript

export const filenameToNoteTitle = (title: string) =>
title.replaceAll('/', ' / ').replaceAll('-', ' ')
export const pathToNotePathTitle = (path: string) => {
const fileNames = path.split('.')
fileNames.pop()
return fileNames
.join('.')
.split('/')
.filter((path) => !path.includes('README'))
.join('/')
.replaceAll('-', ' ')
}
export const pathToNoteTitle = (notePathTitle: string) => {
return pathToNotePathTitle(notePathTitle).split('/').pop()?.trim() ?? ''
}