Return default value to toSlug func
This commit is contained in:
parent
0065eed6e9
commit
8e4e9d1b32
17
lib/utils.js
17
lib/utils.js
@ -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, '')
|
||||||
|
.replaceAll('/','__')
|
||||||
|
.replaceAll(' ','--')
|
||||||
|
.replaceAll('&','ambersand')
|
||||||
|
.replace('.md', '')
|
||||||
|
} else {
|
||||||
|
//TODO handle this properly
|
||||||
|
return '/'
|
||||||
|
}
|
||||||
|
|
||||||
return filePath.replace(postsDirectory, '')
|
|
||||||
.replaceAll('/','__')
|
|
||||||
.replaceAll(' ','--')
|
|
||||||
.replaceAll('&','ambersand')
|
|
||||||
.replace('.md', '')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user