fix: generate paths

This commit is contained in:
iCrawl
2022-11-30 03:17:47 +01:00
parent b0f9b9c344
commit 90d192078f

View File

@@ -111,7 +111,7 @@ export async function generateStaticParams() {
}), }),
]; ];
} catch { } catch {
return { slug: [] }; return { slug: ['packages', '404'] };
} }
}), }),
) )
@@ -162,14 +162,18 @@ async function getData(slug: string[]) {
}); });
let data; let data;
if (process.env.NEXT_PUBLIC_LOCAL_DEV) { try {
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8'); if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
data = JSON.parse(res); const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
} else { data = JSON.parse(res);
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`, { } else {
next: { revalidate: 3_600 }, const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`, {
}); next: { revalidate: 3_600 },
data = await res.json(); });
data = await res.json();
}
} catch {
notFound();
} }
const model = createApiModel(data); const model = createApiModel(data);