From b73fcb132f08d7280c02802482ee566203a2deb4 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 20 Oct 2020 10:04:57 -0500 Subject: [PATCH 1/2] Ensure root-most index GSP page is located correctly --- packages/now-next/src/index.ts | 3 ++- .../test/fixtures/00-i18n-support/pages/index.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts index efb1e93e626..e000dcb72c3 100644 --- a/packages/now-next/src/index.ts +++ b/packages/now-next/src/index.ts @@ -1651,7 +1651,8 @@ export const build = async ({ // if there isn't a srcRoute then it's a non-dynamic SSG page and if (nonDynamicSsg || isFallback) { routeFileNoExt = addLocaleOrDefault( - routeFileNoExt, + // root index files are located without folder/index.html + routeKey === '/' ? '' : routeFileNoExt, routesManifest, locale ); diff --git a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js index 1467602e631..24f4489b20a 100644 --- a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js +++ b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js @@ -44,3 +44,12 @@ export default function Page(props) { ); } + +export const getStaticProps = ({ locale, locales }) => { + return { + props: { + locale, + locales, + }, + }; +}; From 4e667038467a3813325709c436925c4f7913535d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 20 Oct 2020 10:20:59 -0500 Subject: [PATCH 2/2] Update addLocale util --- packages/now-next/src/index.ts | 2 +- packages/now-next/src/utils.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts index e000dcb72c3..978bc0588cd 100644 --- a/packages/now-next/src/index.ts +++ b/packages/now-next/src/index.ts @@ -1652,7 +1652,7 @@ export const build = async ({ if (nonDynamicSsg || isFallback) { routeFileNoExt = addLocaleOrDefault( // root index files are located without folder/index.html - routeKey === '/' ? '' : routeFileNoExt, + routeFileNoExt, routesManifest, locale ); diff --git a/packages/now-next/src/utils.ts b/packages/now-next/src/utils.ts index b68f37a3971..e19f86753ef 100644 --- a/packages/now-next/src/utils.ts +++ b/packages/now-next/src/utils.ts @@ -1110,7 +1110,9 @@ export function addLocaleOrDefault( if (!routesManifest?.i18n) return pathname; if (!locale) locale = routesManifest.i18n.defaultLocale; - return locale ? `/${locale}${pathname}` : pathname; + return locale + ? `/${locale}${pathname === '/index' ? '' : pathname}` + : pathname; } export {