[dyad] Added preview image and copy buttons - wrote 4 file(s)

This commit is contained in:
[dyad]
2026-01-20 12:09:52 +01:00
parent 9c1c4e1581
commit 4163372a17
4 changed files with 100 additions and 19 deletions

View File

@@ -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." };
}

View File

@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { Toaster } from "@/components/ui/sonner";
const geistSans = Geist({
variable: "--font-geist-sans",
@@ -35,6 +36,7 @@ export default function RootLayout({
disableTransitionOnChange
>
{children}
<Toaster richColors />
</ThemeProvider>
</body>
</html>