Skip to content

Commit

Permalink
Prevent _default.md being included in [[...markdownPath]].md
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 29, 2023
1 parent 45e472c commit b5f803f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
File renamed without changes.
5 changes: 4 additions & 1 deletion src/pages/[[...markdownPath]].js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ export async function getStaticPaths() {
: res.slice(rootDir.length + 1);
})
);
return files.flat().filter((file) => file.endsWith('.md'));
return files
.flat()
.filter((file) => file.endsWith('.md') && !file.startsWith('_'));
}

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

const files = await getFiles(rootDir);

const paths = files.map((file) => ({
params: {
markdownPath: getSegments(file),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/errors/[error_code].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const getStaticProps: GetStaticProps<ErrorDecoderProps> = async ({
mdx = fs.readFileSync(rootDir + path + '.md', 'utf8');
} catch {
// if error_code.md is not found, fallback to default.md
mdx = fs.readFileSync(rootDir + '/default.md', 'utf8');
mdx = fs.readFileSync(rootDir + '/_default.md', 'utf8');
}

// See if we have a cached output first.
Expand Down

0 comments on commit b5f803f

Please sign in to comment.