diff --git a/src/app/actions.ts b/src/app/actions.ts index 6c5e2ae..ce6c042 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -7,6 +7,12 @@ interface FaqItem { answer: string; } +interface HeadlineItem { + tag: string; + text: string; + length: number; +} + export async function extractMetaData(url: string) { if (!url) { return { error: "URL is required." }; @@ -73,12 +79,26 @@ export async function extractMetaData(url: string) { } }); + const headlines: HeadlineItem[] = []; + $("h1, h2, h3, h4, h5, h6").each((i, el) => { + const tag = $(el).prop("tagName").toLowerCase(); + const text = $(el).text().trim(); + if (text) { + headlines.push({ + tag, + text, + length: text.length, + }); + } + }); + return { data: { title, description, image, faq: faqData.length > 0 ? faqData : null, + headlines: headlines.length > 0 ? headlines : null, }, }; } catch (error) { diff --git a/src/components/headlines-display.tsx b/src/components/headlines-display.tsx new file mode 100644 index 0000000..970bff8 --- /dev/null +++ b/src/components/headlines-display.tsx @@ -0,0 +1,51 @@ +"use client"; + +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { Badge } from "@/components/ui/badge"; + +interface HeadlinesDisplayProps { + headlines: { + tag: string; + text: string; + length: number; + }[]; +} + +export function HeadlinesDisplay({ headlines }: HeadlinesDisplayProps) { + return ( +