Ignore draft directories in redirects
Some checks are pending
Deploy to Netlify / deploy (push) Waiting to run
Some checks are pending
Deploy to Netlify / deploy (push) Waiting to run
This commit is contained in:
parent
c107b1aed9
commit
b55d8db697
1 changed files with 10 additions and 0 deletions
|
|
@ -16,6 +16,16 @@ const entries = fs.readdirSync(contentDir, { withFileTypes: true });
|
|||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
const slug = entry.name;
|
||||
const postDir = path.join(contentDir, slug);
|
||||
const hasPostFile = ['index.md', 'index.mdx'].some((file) => {
|
||||
const postPath = path.join(postDir, file);
|
||||
return fs.existsSync(postPath) && fs.statSync(postPath).isFile();
|
||||
});
|
||||
|
||||
if (!hasPostFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
redirects.push(`/${slug} /blog/${slug} 200`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue