Return default value to toSlug func

This commit is contained in:
Tuan Cao 2022-04-18 08:10:19 +07:00
parent 0065eed6e9
commit 8e4e9d1b32

View File

@ -75,15 +75,18 @@ export function toFilePath(slug) {
export function toSlug(filePath) { export function toSlug(filePath) {
// Convert File Path to unique slug
// let result = filePath.replace('/','__').replace(' ','-').replace('.md', '')
if (Node.isFile(filePath)) {
return filePath.replace(postsDirectory, '') return filePath.replace(postsDirectory, '')
.replaceAll('/','__') .replaceAll('/','__')
.replaceAll(' ','--') .replaceAll(' ','--')
.replaceAll('&','ambersand') .replaceAll('&','ambersand')
.replace('.md', '') .replace('.md', '')
} else {
//TODO handle this properly
return '/'
}
} }