Skip to content

Commit

Permalink
[next] Ensure root-most index GSP page is located correctly (#5309)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 20, 2020
1 parent 2474a80 commit c120fd8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/now-next/src/index.ts
Expand Up @@ -1651,6 +1651,7 @@ export const build = async ({
// if there isn't a srcRoute then it's a non-dynamic SSG page and
if (nonDynamicSsg || isFallback) {
routeFileNoExt = addLocaleOrDefault(
// root index files are located without folder/index.html
routeFileNoExt,
routesManifest,
locale
Expand Down
4 changes: 3 additions & 1 deletion packages/now-next/src/utils.ts
Expand Up @@ -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 {
Expand Down
Expand Up @@ -44,3 +44,12 @@ export default function Page(props) {
</>
);
}

export const getStaticProps = ({ locale, locales }) => {
return {
props: {
locale,
locales,
},
};
};

0 comments on commit c120fd8

Please sign in to comment.