[dyad] Added preview image and copy buttons - wrote 4 file(s)
This commit is contained in:
@@ -35,12 +35,15 @@ export async function extractMetaData(url: string) {
|
||||
$('meta[property="og:description"]').attr("content") ||
|
||||
$('meta[name="description"]').attr("content") ||
|
||||
"No description found";
|
||||
const image = $('meta[property="og:image"]').attr("content") || null;
|
||||
|
||||
return { data: { title, description } };
|
||||
return { data: { title, description, image } };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Error && error.message.includes('Invalid URL')) {
|
||||
return { error: "The provided URL is not valid. Please check and try again." };
|
||||
if (error instanceof Error && error.message.includes("Invalid URL")) {
|
||||
return {
|
||||
error: "The provided URL is not valid. Please check and try again.",
|
||||
};
|
||||
}
|
||||
return { error: "An unexpected error occurred while fetching the URL." };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user