From b142f3a54cf861119fea1f92c1e80286b2309db2 Mon Sep 17 00:00:00 2001 From: anisite Date: Sun, 26 Mar 2023 11:17:34 -0400 Subject: [PATCH 1/2] Fix generate wrong detect relative path on Windows --- lib/commands/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/generate.js b/lib/commands/generate.js index 9326c24..a62ea95 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -36,7 +36,7 @@ function genSidebar(cwdPath, sidebarPath) { let nodeName = '' getDirFiles(cwdPath, function (pathname) { path.relative(pathname, cwdPath) - pathname = pathname.replace(cwdPath + '/', '') + pathname = pathname.replace(cwdPath + path.sep, '') let filename = path.basename(pathname, '.md') let splitPath = pathname.split(path.sep) From ac679be095432f6087789e4adbb1326b9e41376c Mon Sep 17 00:00:00 2001 From: anisite Date: Sun, 26 Mar 2023 16:11:10 -0400 Subject: [PATCH 2/2] fix not replaced backslash on Windows --- lib/commands/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/generate.js b/lib/commands/generate.js index a62ea95..eb43fbc 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -44,7 +44,7 @@ function genSidebar(cwdPath, sidebarPath) { return true } - nodeName = '- [' + toCamelCase(filename) + '](' + pathname + ')' + os.EOL + nodeName = '- [' + toCamelCase(filename) + '](' + pathname.replace(/\\/g, '/') + ')' + os.EOL if (splitPath.length > 1) { if (splitPath[0] !== lastPath) {