mirror of
https://github.com/ow-mods/ow-mod-db.git
synced 2025-12-11 20:15:24 +01:00
fix silly thumbnail bug ah
This commit is contained in:
parent
fc2a7ff7bd
commit
b2c0f3f0cc
@ -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}`);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user