fix(website): don't crash if no version was found

This commit is contained in:
iCrawl
2025-05-15 22:05:38 +02:00
parent c92a8c27a2
commit 576443c29a
6 changed files with 75 additions and 55 deletions

View File

@@ -19,15 +19,19 @@ export async function fetchNode({
const normalizeItem = item.replaceAll(':', '.').toLowerCase();
if (ENV.IS_LOCAL_DEV) {
const fileContent = await readFile(
join(
process.cwd(),
`${hasEntryPoint || normalizedEntryPoint ? `../../../discord-api-types` : `../../packages/${packageName}`}/docs/${packageName}/split/${version}.${normalizedEntryPoint}${normalizeItem}.api.json`,
),
'utf8',
);
try {
const fileContent = await readFile(
join(
process.cwd(),
`${hasEntryPoint || normalizedEntryPoint ? `../../../discord-api-types` : `../../packages/${packageName}`}/docs/${packageName}/split/${version}.${normalizedEntryPoint}${normalizeItem}.api.json`,
),
'utf8',
);
return JSON.parse(fileContent);
return JSON.parse(fileContent);
} catch {
return null;
}
}
const isMain = version === 'main';