Skip to content

Commit 00b5aa6

Browse files
committed
make rsc-sandbox-test dev-only
1 parent 2bdc76e commit 00b5aa6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/pages/[[...markdownPath]].js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ export async function getStaticPaths() {
139139
const stat = promisify(fs.stat);
140140
const rootDir = process.cwd() + '/src/content';
141141

142+
// Pages that should only be available in development.
143+
const devOnlyPages = new Set(['learn/rsc-sandbox-test']);
144+
142145
// Find all MD files recursively.
143146
async function getFiles(dir) {
144147
const subdirs = await readdir(dir);
@@ -170,14 +173,20 @@ export async function getStaticPaths() {
170173

171174
const files = await getFiles(rootDir);
172175

173-
const paths = files.map((file) => ({
174-
params: {
175-
markdownPath: getSegments(file),
176-
// ^^^ CAREFUL HERE.
177-
// If you rename markdownPath, update patches/next-remote-watch.patch too.
178-
// Otherwise you'll break Fast Refresh for all MD files.
179-
},
180-
}));
176+
const paths = files
177+
.map((file) => ({
178+
params: {
179+
markdownPath: getSegments(file),
180+
// ^^^ CAREFUL HERE.
181+
// If you rename markdownPath, update patches/next-remote-watch.patch too.
182+
// Otherwise you'll break Fast Refresh for all MD files.
183+
},
184+
}))
185+
.filter((entry) => {
186+
if (process.env.NODE_ENV !== 'production') return true;
187+
const pagePath = entry.params.markdownPath.join('/');
188+
return !devOnlyPages.has(pagePath);
189+
});
181190

182191
return {
183192
paths: paths,

0 commit comments

Comments
 (0)