mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: gracefully handle no docs
This commit is contained in:
@@ -34,7 +34,7 @@ export async function fetchModelJSON(packageName: string, version: string): Prom
|
|||||||
return JSON.parse(res);
|
return JSON.parse(res);
|
||||||
} catch {
|
} catch {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
return {};
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ export async function fetchModelJSON(packageName: string, version: string): Prom
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
||||||
return rows[0]?.data ?? {};
|
return rows[0]?.data ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rows } = await sql.execute('select data from documentation where name = ? and version = ?', [
|
const { rows } = await sql.execute('select data from documentation where name = ? and version = ?', [
|
||||||
@@ -54,5 +54,5 @@ export async function fetchModelJSON(packageName: string, version: string): Prom
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
||||||
return rows[0]?.data ?? {};
|
return rows[0]?.data ?? null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,13 +103,18 @@ export async function generateMetadata({ params }: { params: ItemRouteParams })
|
|||||||
|
|
||||||
export async function generateStaticParams({ params: { package: packageName, version } }: { params: ItemRouteParams }) {
|
export async function generateStaticParams({ params: { package: packageName, version } }: { params: ItemRouteParams }) {
|
||||||
const modelJSON = await fetchModelJSON(packageName, version);
|
const modelJSON = await fetchModelJSON(packageName, version);
|
||||||
|
|
||||||
|
if (!modelJSON) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const model = addPackageToModel(new ApiModel(), modelJSON);
|
const model = addPackageToModel(new ApiModel(), modelJSON);
|
||||||
|
|
||||||
const pkg = model.tryGetPackageByName(packageName);
|
const pkg = model.tryGetPackageByName(packageName);
|
||||||
const entry = pkg?.entryPoints[0];
|
const entry = pkg?.entryPoints[0];
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
notFound();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry.members.map((member: ApiItem) => ({
|
return entry.members.map((member: ApiItem) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user