Fixed issue where file name cannot be parsed

This commit is contained in:
Tuan Cao 2022-04-25 12:57:36 +07:00
parent 9cdde4be3e
commit 47d0eb25ba
2 changed files with 9 additions and 4 deletions

View File

@ -125,8 +125,13 @@ export const Transformer = {
},
/* Parse file name from path then sanitize it */
parseFileNameFromPath: function (filepath) {
if (typeof filepath ==='string' && filepath.includes("/")) {
const parsedFileFromPath = filepath.split("/")[filepath.split("/").length - 1]
return parsedFileFromPath.replace(".md", "")
} else {
console.log("Failed: CANNOT Parse" + filepath)
return null
}
},
/* Pair provided and existing Filenames*/
getInternalLinks: function (aFilePath) {

View File

@ -61,7 +61,7 @@ export function toFilePath(slug) {
} else {
filePath = Node.getMarkdownFolder() + slug
.replaceAll('__', '/')
.replaceAll('--', ' ')
.replaceAll('++++', ' ')
.replaceAll('ambersand', '&')
+ ".md";
}
@ -79,7 +79,7 @@ export function toSlug(filePath) {
if (Node.isFile(filePath) && filePath.includes(Node.getMarkdownFolder())) {
return filePath.replace(Node.getMarkdownFolder(), '')
.replaceAll('/', '__')
.replaceAll(' ', '--')
.replaceAll(' ', '++++')
.replaceAll('&', 'ambersand')
.replace('.md', '')
} else {