fix silly thumbnail bug ah

This commit is contained in:
Raicuparta 2025-06-01 20:22:04 +02:00
parent fc2a7ff7bd
commit b2c0f3f0cc
2 changed files with 13 additions and 2 deletions

View File

@ -141,7 +141,7 @@ export async function getFirstImageUrl(
`${GITHUB_RAW_CONTENT_URL}/$1/$2/$3/`
)
: // For relative URLs we also have to resolve them
`${baseUrl}/${imageUrl}`;
`${baseUrl}/${node.destination}`;
return fullUrl;
}
@ -160,6 +160,9 @@ async function downloadImage(
const response = await fetch(imageUrl);
if (!response.ok) {
console.error(
`Failed to download image from url ${imageUrl}: ${response.status} ${response.statusText}`
);
return null;
}
@ -175,6 +178,7 @@ async function downloadImage(
const image = await response.arrayBuffer();
await fsp.writeFile(fullImagePath, Buffer.from(image));
console.log(`Downloaded image from ${imageUrl} to ${fullImagePath}`);
return fullImagePath;
} catch (error) {
console.error(`Failed to download image from url ${imageUrl}: ${error}`);

View File

@ -39,5 +39,12 @@ export async function getReadmeUrls(
export async function getReadmeMarkdown(url: string): Promise<string | null> {
const response = await fetch(url);
return response.status === 200 ? response.text() : null;
if (!response.ok) {
console.error(
`Failed to fetch README from ${url}: ${response.status} ${response.statusText}`
);
return null;
}
return await response.text();
}