diff --git a/lib/utils.js b/lib/utils.js index ce7c149..d83e68d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -75,15 +75,18 @@ export function toFilePath(slug) { 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, '') + .replaceAll('/','__') + .replaceAll(' ','--') + .replaceAll('&','ambersand') + .replace('.md', '') + } else { + //TODO handle this properly + return '/' + } - return filePath.replace(postsDirectory, '') - .replaceAll('/','__') - .replaceAll(' ','--') - .replaceAll('&','ambersand') - .replace('.md', '') }