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

Commit 0d45036

Browse files
committed
use splats for dynamic ssg i18n dataRoutes
1 parent 60e8a49 commit 0d45036

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

lib/pages/getStaticProps/redirects.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,17 @@ pages.forEach(({ route, dataRoute, srcRoute }) => {
109109
force: true,
110110
conditions,
111111
});
112+
113+
if (!isFallbackRoute(srcRoute)) {
114+
redirects.push({
115+
route: getDataRouteForRoute(srcRoute, routeLocale),
116+
target,
117+
force: true,
118+
conditions,
119+
});
120+
}
112121
dynamicLocaleSrcRoutesAdded.push(srcRouteWithLocale);
113122
}
114-
115-
// The dataRoutes for dynamic routes of this page type are correct/specific to
116-
// the prerendered slugs, so we just add one for each dataRoute like normal
117-
// specifically for preview mode (sigh)
118-
redirects.push({
119-
route: dataRoute,
120-
target,
121-
force: true,
122-
conditions,
123-
});
124123
}
125124
} else {
126125
// Add one redirect for the page, but only when the NextJS

tests/__snapshots__/i18n.test.js.snap

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ exports[`Routing creates Netlify redirects 1`] = `
88
/_next/data/%BUILD_ID%/en/getServerSideProps/all/* /.netlify/functions/next_getServerSideProps_all_slug 200
99
/_next/data/%BUILD_ID%/en/getServerSideProps/static.json /.netlify/functions/next_getServerSideProps_static 200
1010
/_next/data/%BUILD_ID%/en/getServerSideProps/:id.json /.netlify/functions/next_getServerSideProps_id 200
11-
/_next/data/%BUILD_ID%/en/getStaticProps/1.json /.netlify/functions/next_getStaticProps_id 200! Cookie=__prerender_bypass,__next_preview_data
12-
/_next/data/%BUILD_ID%/en/getStaticProps/2.json /.netlify/functions/next_getStaticProps_id 200! Cookie=__prerender_bypass,__next_preview_data
1311
/_next/data/%BUILD_ID%/en/getStaticProps/static.json /.netlify/functions/next_getStaticProps_static 200! Cookie=__prerender_bypass,__next_preview_data
1412
/_next/data/%BUILD_ID%/en/getStaticProps/with-revalidate.json /.netlify/functions/next_getStaticProps_withrevalidate 200
15-
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/3.json /.netlify/functions/next_getStaticProps_withFallback_id 200! Cookie=__prerender_bypass,__next_preview_data
16-
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/4.json /.netlify/functions/next_getStaticProps_withFallback_id 200! Cookie=__prerender_bypass,__next_preview_data
17-
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/my/path/1.json /.netlify/functions/next_getStaticProps_withFallback_slug 200! Cookie=__prerender_bypass,__next_preview_data
18-
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/my/path/2.json /.netlify/functions/next_getStaticProps_withFallback_slug 200! Cookie=__prerender_bypass,__next_preview_data
1913
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/:id.json /.netlify/functions/next_getStaticProps_withFallback_id 200
2014
/_next/data/%BUILD_ID%/en/getStaticProps/withFallback/:slug/* /.netlify/functions/next_getStaticProps_withFallback_slug 200
2115
/_next/data/%BUILD_ID%/en/getStaticProps/withRevalidate/withFallback/:id.json /.netlify/functions/next_getStaticProps_withRevalidate_withFallback_id 200
2216
/_next/data/%BUILD_ID%/en/getStaticProps/withRevalidate/:id.json /.netlify/functions/next_getStaticProps_withRevalidate_id 200
17+
/_next/data/%BUILD_ID%/en/getStaticProps/:id.json /.netlify/functions/next_getStaticProps_id 200! Cookie=__prerender_bypass,__next_preview_data
2318
/_next/data/%BUILD_ID%/es/getServerSideProps/all.json /.netlify/functions/next_getServerSideProps_all_slug 200
2419
/_next/data/%BUILD_ID%/es/getServerSideProps/all/* /.netlify/functions/next_getServerSideProps_all_slug 200
2520
/_next/data/%BUILD_ID%/es/getServerSideProps/static.json /.netlify/functions/next_getServerSideProps_static 200

0 commit comments

Comments
 (0)