Skip to content

Commit b5f803f

Browse files
committed
Prevent _default.md being included in [[...markdownPath]].md
1 parent 45e472c commit b5f803f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
File renamed without changes.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ export async function getStaticPaths() {
266266
: res.slice(rootDir.length + 1);
267267
})
268268
);
269-
return files.flat().filter((file) => file.endsWith('.md'));
269+
return files
270+
.flat()
271+
.filter((file) => file.endsWith('.md') && !file.startsWith('_'));
270272
}
271273

272274
// 'foo/bar/baz.md' -> ['foo', 'bar', 'baz']
@@ -280,6 +282,7 @@ export async function getStaticPaths() {
280282
}
281283

282284
const files = await getFiles(rootDir);
285+
283286
const paths = files.map((file) => ({
284287
params: {
285288
markdownPath: getSegments(file),

src/pages/errors/[error_code].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const getStaticProps: GetStaticProps<ErrorDecoderProps> = async ({
127127
mdx = fs.readFileSync(rootDir + path + '.md', 'utf8');
128128
} catch {
129129
// if error_code.md is not found, fallback to default.md
130-
mdx = fs.readFileSync(rootDir + '/default.md', 'utf8');
130+
mdx = fs.readFileSync(rootDir + '/_default.md', 'utf8');
131131
}
132132

133133
// See if we have a cached output first.

0 commit comments

Comments
 (0)