mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
fix: prerender bailout
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { ENV } from './env';
|
||||
|
||||
export async function fetchNode({
|
||||
@@ -15,32 +14,22 @@ export async function fetchNode({
|
||||
const normalizeItem = item.split(encodeURIComponent(':')).join('.').toLowerCase();
|
||||
|
||||
if (ENV.IS_LOCAL_DEV) {
|
||||
try {
|
||||
const fileContent = await readFile(
|
||||
join(
|
||||
process.cwd(),
|
||||
`../../packages/${packageName}/docs/${packageName}/split/${version}.${normalizeItem}.api.json`,
|
||||
),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
return JSON.parse(fileContent);
|
||||
} catch (error_) {
|
||||
console.error(error_);
|
||||
notFound();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const isMainVersion = version === 'main';
|
||||
const fileContent = await fetch(
|
||||
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
|
||||
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
|
||||
const fileContent = await readFile(
|
||||
join(
|
||||
process.cwd(),
|
||||
`../../packages/${packageName}/docs/${packageName}/split/${version}.${normalizeItem}.api.json`,
|
||||
),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
return await fileContent.json();
|
||||
} catch (error_) {
|
||||
console.error(error_);
|
||||
notFound();
|
||||
return JSON.parse(fileContent);
|
||||
}
|
||||
|
||||
const isMainVersion = version === 'main';
|
||||
const fileContent = await fetch(
|
||||
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
|
||||
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
|
||||
);
|
||||
|
||||
return fileContent.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user