"use client"; import { Globe } from "lucide-react"; import { KeywordHighlighter } from "./keyword-highlighter"; interface SerpPreviewProps { title: string; description: string; url: string; keyword?: string | null; } export function SerpPreview({ title, description, url, keyword, }: SerpPreviewProps) { const formatUrl = (fullUrl: string) => { try { let formattedUrl = fullUrl; if (!/^https?:\/\//i.test(fullUrl)) { formattedUrl = `https://${fullUrl}`; } const urlObject = new URL(formattedUrl); const path = urlObject.pathname === "/" ? "" : urlObject.pathname; // remove trailing slash const displayPath = path.endsWith("/") ? path.slice(0, -1) : path; return `${urlObject.hostname}${displayPath}`; } catch (error) { return fullUrl; } }; const displayUrl = formatUrl(url); return (

{displayUrl.split("/")[0]}

{displayUrl}

); }