From 8e4e9d1b32e710471cabf94e77aa832e96ec0259 Mon Sep 17 00:00:00 2001 From: Tuan Cao Date: Mon, 18 Apr 2022 08:10:19 +0700 Subject: [PATCH] Return default value to toSlug func --- lib/utils.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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', '') }