Skip to content

Commit 0123ec4

Browse files
committed
fix(build): exclude errors content on Windows
getStaticPaths sliced platform-native paths, so on Windows the errors/ prefix check saw errors\\*.md and never excluded it; getSegments then normalized the path to /errors/*, colliding with pages/errors. Normalize content paths to forward slashes when collected and drop the redundant normalization in getSegments. Verified with a full yarn build (exit 0).
1 parent 5e3a0f3 commit 0123ec4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/pages/[[...markdownPath]].js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export async function getStaticPaths() {
150150
const res = resolve(dir, subdir);
151151
return (await stat(res)).isDirectory()
152152
? getFiles(res)
153-
: res.slice(rootDir.length + 1);
153+
: res.slice(rootDir.length + 1).replace(/\\/g, '/');
154154
})
155155
);
156156
return (
@@ -164,7 +164,7 @@ export async function getStaticPaths() {
164164
// 'foo/bar/baz.md' -> ['foo', 'bar', 'baz']
165165
// 'foo/bar/qux/index.md' -> ['foo', 'bar', 'qux']
166166
function getSegments(file) {
167-
let segments = file.slice(0, -3).replace(/\\/g, '/').split('/');
167+
let segments = file.slice(0, -3).split('/');
168168
if (segments[segments.length - 1] === 'index') {
169169
segments.pop();
170170
}

0 commit comments

Comments
 (0)