fix: handle empty markdown
All checks were successful
Deploy to SFTP Server / build (push) Successful in 10m50s
All checks were successful
Deploy to SFTP Server / build (push) Successful in 10m50s
This commit is contained in:
@@ -17,13 +17,16 @@ export async function generateThumbHash(
|
||||
|
||||
if (!imagePath) return;
|
||||
|
||||
if (imagePath.endsWith(".svg")) return;
|
||||
|
||||
let sp: ReturnType<typeof sharp>;
|
||||
if (imagePath.startsWith("https://") || imagePath.startsWith("http://")) {
|
||||
const res = await fetch(imagePath);
|
||||
if (!res.ok) {
|
||||
return;
|
||||
}
|
||||
sp = sharp(await res.arrayBuffer());
|
||||
const buffer = await res.arrayBuffer();
|
||||
sp = sharp(buffer);
|
||||
} else {
|
||||
sp = sharp(imagePath);
|
||||
}
|
||||
@@ -44,10 +47,9 @@ export async function generateThumbHash(
|
||||
|
||||
const buffer = rgbaToThumbHash(smallWidth, smallHeight, smallImg);
|
||||
return Buffer.from(buffer).toString("base64");
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log(
|
||||
`Could not generate thumbhash for ${image.fsPath ?? image.src}`,
|
||||
error,
|
||||
);
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user