mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 13:52:36 +02:00
broken links: we should ignore folders when looking for existing files in the build folder (#3107)
This commit is contained in:
parent
a78f703366
commit
6aec331963
1 changed files with 7 additions and 4 deletions
|
@ -130,14 +130,17 @@ async function filterExistingFileLinks({
|
||||||
allCollectedLinks: Record<string, string[]>;
|
allCollectedLinks: Record<string, string[]>;
|
||||||
}): Promise<Record<string, string[]>> {
|
}): Promise<Record<string, string[]>> {
|
||||||
// not easy to make this async :'(
|
// not easy to make this async :'(
|
||||||
function linkFileDoesNotExist(link: string): boolean {
|
function linkFileExists(link: string): boolean {
|
||||||
const filePath = `${outDir}/${removePrefix(link, baseUrl)}`;
|
const filePath = `${outDir}/${removePrefix(link, baseUrl)}`;
|
||||||
const exists = fs.existsSync(filePath);
|
try {
|
||||||
return !exists;
|
return fs.statSync(filePath).isFile(); // only consider files
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapValues(allCollectedLinks, (links) => {
|
return mapValues(allCollectedLinks, (links) => {
|
||||||
return links.filter(linkFileDoesNotExist);
|
return links.filter((link) => !linkFileExists(link));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue