"use client"; import { Globe } from "lucide-react"; interface SerpPreviewProps { title: string; description: string; url: string; } export function SerpPreview({ title, description, url }: 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}
{description || "This is where the meta description will be displayed. It provides a brief summary of the page's content for search engine users."}