Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit a691fef

Browse files
committed
SSG'd root level index page needs special dataRoute logic
1 parent 04d57b4 commit a691fef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/pages/getStaticProps/setup.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,22 @@ const setup = ({ functionsPath, publishPath }) => {
4040
const htmlPath = getFilePathForRoute(route_, "html", locale);
4141
setupStaticFileForPage({ inputPath: htmlPath, publishPath });
4242

43-
const jsonPath = getFilePathForRoute(route_, "json", locale);
4443
// The provided dataRoutes (from prerender-manifest) for these page types
4544
// actually don't include the locale (unclear why Vercel did this)
4645
// BUT the actual path to the .json files DO include the locale
4746
// therefore we need to set up the .json pages in the locale loop and
4847
// ignore the dataRoute provided by the prerender-manifest
49-
const i18nDataRoute = getDataRouteForRoute(route, locale);
48+
// Also root-level pages are generated into dist at path -> /en/index.json
49+
// but fetched on the client as /_next/data/{BUILD_ID}/en.json haha love that for me
50+
const jsonPath =
51+
route === "/"
52+
? getFilePathForRoute(`/${locale}`, "json")
53+
: getFilePathForRoute(route_, "json", locale);
54+
const i18nDataRoute =
55+
route === "/"
56+
? getDataRouteForRoute(`/${locale}`)
57+
: getDataRouteForRoute(route, locale);
58+
const hack2 = getDataRouteForRoute(`/${locale}`);
5059
setupStaticFileForPage({
5160
inputPath: jsonPath,
5261
outputPath: i18nDataRoute,

0 commit comments

Comments
 (0)