diff --git a/packages/core/src/page/inferPagePath.ts b/packages/core/src/page/inferPagePath.ts index 098e79985a..8d082ea93c 100644 --- a/packages/core/src/page/inferPagePath.ts +++ b/packages/core/src/page/inferPagePath.ts @@ -27,7 +27,7 @@ export const inferPagePath = ({ // infer page route path from file path // foo/bar.md -> /foo/bar.html - const pathInferred = ensureLeadingSlash(inferRoutePath(filePathRelative)) + const pathInferred = inferRoutePath(ensureLeadingSlash(filePathRelative)) // resolve page locale path const pathLocale = resolveLocalePath(app.siteData.locales, pathInferred) diff --git a/packages/core/tests/page/inferPagePath.spec.ts b/packages/core/tests/page/inferPagePath.spec.ts index f65aced2ad..faac1b12b3 100644 --- a/packages/core/tests/page/inferPagePath.spec.ts +++ b/packages/core/tests/page/inferPagePath.spec.ts @@ -21,6 +21,13 @@ const appWithoutLocales = createBaseApp({ }) const TEST_CASES: [string, ReturnType][] = [ + [ + 'README.md', + { + pathInferred: '/', + pathLocale: '/', + }, + ], [ 'foo.md', { @@ -28,6 +35,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/', }, ], + [ + 'en/README.md', + { + pathInferred: '/en/', + pathLocale: '/en/', + }, + ], [ 'en/foo.md', { @@ -35,6 +49,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/en/', }, ], + [ + 'zh/README.md', + { + pathInferred: '/zh/', + pathLocale: '/zh/', + }, + ], [ 'zh/foo.md', { @@ -42,6 +63,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/zh/', }, ], + [ + '中文/README.md', + { + pathInferred: '/中文/', + pathLocale: '/中文/', + }, + ], [ '中文/foo.md', {