refactor: switch to vercel blob for docs

This commit is contained in:
iCrawl
2023-11-13 23:15:16 +01:00
parent ffc3ea5c3f
commit 01c63d2e0f
9 changed files with 278 additions and 69 deletions

View File

@@ -32,18 +32,20 @@ export const fetchModelJSON = async (packageName: string, version: string) => {
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
try {
const { rows } = await sql`select data from documentation where name = ${packageName} and version = ${'main'}`;
const { rows } = await sql`select url from documentation where name = ${packageName} and version = ${'main'}`;
const res = await fetch(rows[0]?.url ?? '');
return rows[0]?.data ?? null;
return await res.json();
} catch {
return null;
}
}
try {
const { rows } = await sql`select data from documentation where name = ${packageName} and version = ${version}`;
const { rows } = await sql`select url from documentation where name = ${packageName} and version = ${version}`;
const res = await fetch(rows[0]?.url ?? '');
return rows[0]?.data ?? null;
return await res.json();
} catch {
return null;
}