Skip to content

Commit c0636ab

Browse files
committed
sync-a3e9466d
1 parent 47ffd6a commit c0636ab

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

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

+29-11
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,30 @@ export async function getStaticProps(context) {
109109
try {
110110
mdx = fs.readFileSync(rootDir + path + '.md', 'utf8');
111111
} catch {
112-
mdx = fs.readFileSync(rootDir + path + '/index.md', 'utf8');
112+
try {
113+
mdx = fs.readFileSync(rootDir + path + '/index.md', 'utf8');
114+
} catch {
115+
return {
116+
notFound: true,
117+
};
118+
}
113119
}
114120

115-
const {toc, content, meta, languages} = await compileMDX(mdx, path, {});
116-
return {
117-
props: {
118-
toc,
119-
content,
120-
meta,
121-
languages,
122-
},
123-
};
121+
try {
122+
const {toc, content, meta, languages} = await compileMDX(mdx, path, {});
123+
return {
124+
props: {
125+
toc,
126+
content,
127+
meta,
128+
languages,
129+
},
130+
};
131+
} catch (error) {
132+
return {
133+
notFound: true,
134+
};
135+
}
124136
}
125137

126138
// Collect all MDX files for static generation.
@@ -172,8 +184,14 @@ export async function getStaticPaths() {
172184
},
173185
}));
174186

187+
// Filter out paths that start with 'errors'
188+
const filteredPaths = paths.filter((path) => {
189+
const segments = path.params.markdownPath;
190+
return !segments || segments[0] !== 'errors';
191+
});
192+
175193
return {
176-
paths: paths,
194+
paths: filteredPaths,
177195
fallback: false,
178196
};
179197
}

0 commit comments

Comments
 (0)